java - Message-Driven Bean reads two times the same message -


good morning in timezone.

application server -> 7 ejb 3.0

in project working on, using message-driven bean read messages queue. message-driven bean read 2 times same message , in second read throws exception because integrity constraint in database insert. why message-driven bean reading message 2 times. using 1 listener on queue , there 1 mdb attached listener. using following activationconfigproperty through annotations 1 messageselector 2 destinationtype 3 destination

code snippet

@messagedriven(activationconfig = {     @activationconfigproperty(propertyname = "messageselector", propertyvalue = "responsetype = 'xxxxx'"),     @activationconfigproperty(propertyname = "destinationtype", propertyvalue = "javax.jms.queue"),     @activationconfigproperty(propertyname = "destination", propertyvalue = "jms/yyyy")}) 

thanks in advance best regards

@messagedriven(activationconfig = {     @activationconfigproperty(propertyname = "destinationlookup", propertyvalue = "java:/jms/queue/data"),     @activationconfigproperty(propertyname = "destinationtype", propertyvalue = "javax.jms.queue"),     @activationconfigproperty(propertyname = "acknowledgemode", propertyvalue = "auto-acknowledge") }) 

use configuration specifying acknowledgement message,i think need specify destinationlookup or destination property specifying strict point point communication.

use message listener verify when message being received , time live message being published

@stateless public class messagesender {      @inject     jmscontext jmscontext;      public void sendmessage(string message, destination destination) {         jmsproducer messageproducer = jmscontext.createproducer().setasync(                 new completionlistener() {                      public void onexception(message message, exception exception) {                         system.out                                 .println("message not delivered!!!!\nan exception has occured "                                         + exception);                      }                      public void oncompletion(message message) {                         system.out                                 .println("message  delivered : hooah ");                      }                 });         // check if both messages getting expired after mentioned time         messageproducer.settimetolive(6000);         messageproducer.send(destination, message);     }  } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -