[jboss-user] [EJB3] - A question about the transaction?

Michael Owen do-not-reply at jboss.com
Tue Jun 18 02:53:56 EDT 2013


Michael Owen [https://community.jboss.org/people/liverpoolilove] created the discussion

"A question about the transaction?"

To view the discussion, visit: https://community.jboss.org/message/823591#823591

--------------------------------------------------------------
I created an MDB in my project.As follows:

/**
 * Message-Driven Bean implementation class for: QueueListenerMDB
 */
@MessageDriven(activationConfig = {
                    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                    @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/test") })
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class QueueListenerMDB implements MessageListener {
          /**
           * Default constructor.
           */
          public QueueListenerMDB() {
          }


          /**
           * @see MessageListener#onMessage(Message)
           */
          public void onMessage(Message message) {
                    sendMessage(message);
          }


          public void sendMessage(Message message) {
                    try {
                              if (message instanceof TextMessage) {
                                        System.out.println("Queue: I received a TextMessage at "
                                                            + new Date());
                                        TextMessage msg = (TextMessage) message;
                                        System.out.println("Message is : " + msg.getText());
                              } else if (message instanceof ObjectMessage) {
                                        System.out.println("Queue: I received an ObjectMessage at "
                                                            + new Date());
                                        ObjectMessage msg = (ObjectMessage) message;
                                        DBTrigger trigger = (DBTrigger) msg.getObject();

                                        triggerService.saveTrigger(trigger);

                                        System.out.println("trigger Details: ");
                                        System.out.println(trigger);
                              } else {
                                        System.out.println("Not valid message for this Queue MDB");
                              }
                    } catch (JMSException e) {
                              e.printStackTrace();
                    }
          }
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/823591#823591]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130618/a7514c20/attachment-0001.html 


More information about the jboss-user mailing list