Question

I learning Hornetq code recently, and have a doubt about JMSbridge.

you can see, there has a fun named "sendMessages()" in the JMSbridgeImpl.java. the fun send msg to the remote JMSServer, but without doing acknowledge.

but int the fun named "sendBatchNonTransacted()" , there just dong acknowledge with the last msg, such as "messages.getLast().acknowledge();"

so the question is: why not do ack by the each msg in the fun named "sendMessages()"?

apologize, my English is pool.

I'm online waiting for you help! thank you !

--------------------------------------------

oh, thanks "Moj Far" very much for the frist question, i got it.

but i have a other question: i modifid the hornetQ source codes, i want to use ClientConsumer(have successful init) to get msg in the local HornetQ
and use JMS producer to send msg to the remote JMSServer.

In the "Run" function of the "SourceReceiver" class, i modyfy as this:

if (bridgeType == JMSBridgeImpl.ALL_NETTY_MODE ) {
    msg = sourceConsumer.receive(1000);
} else {        /* core client receive msg */
    cmsg = localClientConsumer.receive(1000);
    if (cmsg != null) {
        hq_msg = HornetQMessage.createMessage(cmsg, localClientSession);
        //hq_msg = HornetQMessage.createMessage(cmsg, null);
        hq_msg.doBeforeReceive();
        //cmsg.acknowledge();       do ack after send
        msg = hq_msg;
    }
}                                   

but after 2 hours runing, the VM memary is Overflow.

i alsotry to not use localClientSession to create HornetQMessage,but the memory is also Overflow.

is there something wrong in my code?

Was it helpful?

Solution

We have two ways for guarantee of sending messages:

  1. Transactional (used in sendBatchLocalTx() and sendBatchXA())
  2. Non Transactional or Acknowledgement (used in sendBatchNonTransacted())

All of sendBatchLocalTx(), sedBatchXA(), and sendBatchNonTransacted(), use sendMessages() for sending messages, then guarantee sending messages with their own way (commit a transaction or ack messages)!

In sendBatchNonTransacted(), it uses Client Acknowledgement Mode; In this mode, with acking a message (here, the last message), all sent messages in current session will be acked!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top