I seem to be losing some messages in a network of brokers topology in the
following setup:

- 1 producer pushing messages to a persistent queue (let’s call it
“IN.QUEUE.Broker1”) on one broker (broker1) inside a transaction. Producer
commits in every 100 messages.

- IN.QUEUE is a composite queue which forwards the messages to another queue
in broker1 (let’s call this “Q1”). Network of brokers is configured to
forward messages from Q1 to broker2. Q1 is listed in
staticallyIncludedDestinations so it will always forward. 

- There are no consumers. I am looking at the message counts from AMQ web
interface once all messages are in.

- Second broker (broker2) is connected to broker1 via network of brokers
(configuration below).

My test case:
1.      Purge all messages in all queues
2.      Start producer and send 10,000 messages to IN.QUEUE in broker1. At this
point, I start to see messages forwarded to broker2.
3.      Stop/kill broker2. I am running the brokers in console. So in order to
kill the broker I just kill the console. At this point I am seeing the
messages accumulated in broker1.
4.      Start broker2.
5.      When all 10,000 is sent, I look at the total number of messages in each
broker and they are same. I just run the test again and I have 9981 messages
in broker2 instead of 10,000. I can replicate this whenever I run this test.

I also looked at https://issues.apache.org/jira/browse/AMQ-1845. My issue
seems to be similar with this. So I converted my code from Spring jms
template to Apache NMS. But issue is still there.

Can you please advise whether this is a known issue or something is wrong in
my configuration?

CONFIGURATION in BROKER1:

<destinationInterceptors>
  <virtualDestinationInterceptor>
        <virtualDestinations>
          <compositeQueue name="IN.Broker1">
                <forwardTo>
                  <queue physicalName="Q1" />
                </forwardTo>
          </compositeQueue>
        </virtualDestinations>
  </virtualDestinationInterceptor>
</destinationInterceptors>

<networkConnectors>
        <networkConnector 
                uri="static:(tcp://localhost:61617)"
                name="FromB1ToB2"
                conduitSubscriptions="false"
                decreaseNetworkConsumerPriority="false"
                prefetchSize="1"
                >
        <staticallyIncludedDestinations>
                <queue physicalName="Q1" />
        </staticallyIncludedDestinations> 
  </networkConnector>
</networkConnectors>

PRODUCER CODE:

var textMessage = GetMessageContent();
var connectionFactory = new ConnectionFactory(ServerUri);

using (var connection = connectionFactory.CreateConnection())
{
        connection.Start();

        using (var session =
connection.CreateSession(AcknowledgementMode.Transactional))
        {
                var queue = session.GetQueue(destination);
                using (var producer = session.CreateProducer(queue))
                {
                        producer.DeliveryMode = MsgDeliveryMode.Persistent;

                        for (int i = 1; i < numberOfMessagesToSend+1; i++)
                        {
                                var message = 
producer.CreateTextMessage(textMessage);
                                producer.Send(message);

                                if (i % 100 == 0)
                                {
                                        session.Commit();
                                }
                        }
                }
        }
}

Cheers,
Ozan

--
View this message in context: 
http://activemq.2283324.n4.nabble.com/Message-loss-in-network-of-brokers-transactional-send-tp3588714p3588714.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to