i work on a project with activemq java and i use ssl or udp connection .To receive messqge i use a QeueueReceiver and MessageListener Classes .the problem is that the ssl connection perfectly but when i choose a udp connection and i send 7 messages and i put the listener working i receive 5 messages after i receive only 2 messages . i DONT know what exactly the problem sombedoy can help please there is a code
code ry { switch (protocol) { case "UDP": connectionFactoryUDP = new ActiveMQConnectionFactory(brokerUrlUDP); connection = connectionFactoryUDP.createQueueConnection(username, password);
break;
case "TLS":
connectionFactoryTLS = new ActiveMQSslConnectionFactory();
// create connection
connectionFactoryTLS.setBrokerURL(brokerUrlTLS);
connectionFactoryTLS.setTrustStore(trustStore);
connectionFactoryTLS.setTrustStorePassword(trustStorePassword);
connectionFactoryTLS.setKeyStore(keyStore);
connectionFactoryTLS.setKeyStorePassword(keyStorePassword);
connection = connectionFactoryTLS.createQueueConnection(username,password);
break;}
//ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(this.username, this.password, "tcp://localhost:61616");
// create connection
// start
connection.start();
// create session
// create queue (it will create if queue doesn't exist)
// create listener
System.out.println("____________________________________");
MessageListener messageListener = new MessageListener() {
@Override
public void onMessage(Message message) {
System.out.println("____________________________________");
// only text type message
if (message instanceof TextMessage) {
TextMessage txt = (TextMessage) message;
try {
System.out.println("Message received =---_________--" + txt.getText());
} catch (JMSException e) {
System.out.println("error retrieving message");
System.exit(1);
}
}
}
};
session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(queueName);
QueueReceiver consumer = session.createReceiver(queue);
consumer.setMessageListener(messageListener);
System.in.read();
consumer.close();
session.close();
connection.close();
System.out.println("-----------closed----------");
log console 2015-10-16 18:30:42 DEBUG UdpTransport:382 - Binding to address: 0.0.0.0/0.0.0.0:0 2015-10-16 18:30:42 DEBUG Connection:1:55 - SENDING: ConnectionInfo {commandId = 1, responseRequired = true, connectionId = ID:aymenmhidhi-PC-57832-1445013042216-1:1, clientId = ID:aymenmhidhi-PC-57832-1445013042216-0:1, clientIp = null, userName = aymenmhidhi, password = *****, brokerPath = null, brokerMasterConnector = false, manageable = true, clientMaster = true, faultTolerant = false, failoverReconnect = false} 2015-10-16 18:30:42 DEBUG UdpTransport:124 - Sending oneway from: udp://localhost:61625?trace=true@49257 to target: localhost/127.0.0.1:61625 command: ConnectionInfo {commandId = 1, responseRequired = true, connectionId = ID:aymenmhidhi-PC-57832-1445013042216-1:1, clientId = ID:aymenmhidhi-PC-57832-1445013042216-0:1, clientIp = null, userName = aymenmhidhi, password = *****, brokerPath = null, brokerMasterConnector = false, manageable = true, clientMaster = true, faultTolerant = false, failoverReconnect = false} 2015-10-16 18:30:42 DEBUG DefaultReplayBuffer:47 - Adding command ID: 1 to replay buffer: org.apache.activemq.transport.reliable.DefaultReplayBuffer@7e3e2cff object: java.nio.DirectByteBuffer[pos=129 lim=4096 cap=4096] 2015-10-16 18:30:42 DEBUG CommandDatagramChannel:242 - Channel: udp://localhost:61625?trace=true@49257 sending datagram: 1 to: localhost/127.0.0.1:61625 2015-10-16 18:30:42 DEBUG CommandDatagramChannel:110 - Channel: udp://localhost:61625?trace=true@49257 received from: Endpoint[name:/127.0.0.1:49258] about to process: Response {commandId = 1, responseRequired = false, correlationId = 1} 2015-10-16 18:30:42 DEBUG Connection:1:60 - RECEIVED: Response {commandId = 1, responseRequired = false, correlationId = 1} 2015-10-16 18:30:42 DEBUG CommandDatagramChannel:110 - Channel: udp://localhost:61625?trace=true@49257 received from: Endpoint[name:/127.0.0.1:49258] about to process: ConnectionControl {commandId = 2, responseRequired = false, suspend = false, resume = false, close = false, exit = false, faultTolerant = false, connectedBrokers = , reconnectTo = , token = null, rebalanceConnection = false} 2015-10-16 18:30:42 DEBUG Connection:1:60 - RECEIVED: ConnectionControl {commandId = 2, responseRequired = false, suspend = false, resume = false, close = false, exit = false, faultTolerant = false, connectedBrokers = , reconnectTo = , token = null, rebalanceConnection = false} 2015-10-16 18:30:42 DEBUG CommandDatagramChannel:110 - Channel: udp://localhost:61625?trace=true@49257 received from: Endpoint[name:/127.0.0.1:49258] about to process: BrokerInfo {commandId = 3, responseRequired = false, brokerId = ID:aymenmhidhi-PC-57133-1445011516433-0:1, brokerURL = tcp://aymenmhidhi-PC:61616, slaveBroker = false, masterBroker = false, faultTolerantConfiguration = false, networkConnection = false, duplexConnection = false, peerBrokerInfos = null, brokerName = localhost, connectionId = 0, brokerUploadUrl = null, networkProperties = null} 2015-10-16 18:30:42 DEBUG Connection:1:60 - RECEIVED: BrokerInfo {commandId = 3, responseRequired = false, brokerId = ID:aymenmhidhi-PC-57133-1445011516433-0:1, brokerURL = tcp://aymenmhidhi-PC:61616, slaveBroker = false, masterBroker = false, faultTolerantConfiguration = false, networkConnection = false, duplexConnection = false, peerBrokerInfos = null, brokerName = localhost, connectionId = 0, brokerUploadUrl = null, networkProperties = null} 2015-10-16 18:30:42 DEBUG Connection:1:55 - SENDING: ConsumerInfo {commandId = 2, responseRequired = true, consumerId = ID:aymenmhidhi-PC-57832-1445013042216-1:1:-1:1, destination = ActiveMQ.Advisory.TempQueue,ActiveMQ.Advisory.TempTopic, prefetchSize = 1000, maximumPendingMessageLimit = 0, browser = false, dispatchAsync = true, selector = null, clientId = null, subscriptionName = null, noLocal = true, exclusive = false, retroactive = false, priority = 0, brokerPath = null, optimizedAcknowledge = false, noRangeAcks = false, additionalPredicate = null} 2015-10-16 18:30:42 DEBUG UdpTransport:124 - Sending oneway from: udp://localhost:61625?trace=true@49257 to target: /127.0.0.1:49258 command: ConsumerInfo {commandId = 2, responseRequired = true, consumerId = ID:aymenmhidhi-PC-57832-1445013042216-1:1:-1:1, destination = ActiveMQ.Advisory.TempQueue,ActiveMQ.Advisory.TempTopic, prefetchSize = 1000, maximumPendingMessageLimit = 0, browser = false, dispatchAsync = true, selector = null, clientId = null, subscriptionName = null, noLocal = true, exclusive = false, retroactive = false, priority = 0, brokerPath = null, optimizedAcknowledge = false, noRangeAcks = false, additionalPredicate = null} 2015-10-16 18:30:42 DEBUG DefaultReplayBuffer:47 - Adding command ID: 2 to replay buffer: org.apache.activemq.transport.reliable.DefaultReplayBuffer@7e3e2cff object: java.nio.DirectByteBuffer[pos=155 lim=4096 cap=4096] 2015-10-16 18:30:42 DEBUG CommandDatagramChannel:242 - Channel: udp://localhost:61625?trace=true@49257 sending datagram: 2 to: /127.0.0.1:49258 2015-10-16 18:30:42 DEBUG CommandDatagramChannel:110 - Channel: udp://localhost:61625?trace=true@49257 received from: Endpoint[name:/127.0.0.1:49258] about to process: Response {commandId = 4, responseRequired = false, correlationId = 2} 2015-10-16 18:30:42 DEBUG Connection:1:60 - RECEIVED: Response {commandId = 4, responseRequired = false, correlationId = 2}
brokerurl brokerUrlUDP=udp://localhost:61625?trace=true
Thanks.