Discussions

General J2EE: MDB as Subscriber to MQ series Publishing/Subscribing facility

  1. Hi All,
    Can any one please tell me how I can make a Message Driven Bean to subscribe to a MQ Topic using MQ Series's Publishing / Subscribing facility. Will appreciate If I can get a detailed explanation/direction to do so OR information about some material where I can get related details.

    Its bit urgent for me. Any help would be highly appreciated.

    Thanks and kind regards,
    Ravi

    Threaded Messages (5)

  2. Which app server are you using?[ Go to top ]

    Application servers allows Message-Driven Beans to listen on destinations hosted from a foreign provider, such as MQ-Series. Since you did not specify which application server you are using, then I can't really help you in that regard, but I do know how you can configure an MDB in Weblogic to listen on a foreign destination. All you need to do is specify a few configuration settings in the application server-specific deployment descriptor for the MDB.

    These links should help since they show you how to set up Weblogic to access a foreign provider. There is also sample code to assist you.

    Hope it helps!!

    http://edocs.bea.com/wls/docs81/ConsoleHelp/jms_config.html#1115305

    http://dev2dev.bea.com/codelibrary/code/sample_mdb.jsp
  3. Which app server are you using?[ Go to top ]

    Hi,
    thanks for the reply, I am using IBM Websphere 5.0. We plan to use embedded JMS provided with Websphere 5.0 rather than going for seperate enterprise MQ. Please suggest how to go about it for above scenario.

    Many thanks.
    Ravi..
  4. IBM InfoCenter for WAS 5.0[ Go to top ]

    Ravi,

    Have you looked at the InfoCenter for WAS 5?

    http://publib.boulder.ibm.com/infocenter/wasinfo/topic/com.ibm.websphere.nd.doc/info/ae/ae/tmb_ep.html

    It shows you how to design, develop, and deploy MDBs for WAS 5.

    Three steps to deployment:

    Use the WebSphere administrative console to define the listener ports for the application, as described in Adding a new listener port.

    For each message-driven bean in the application, use the application assembly tool to configure the deployment attributes to match the listener port definitions, as described in Configuring deployment attributes for a message-driven bean.

    Launch the Application Assembly Tool.
    Create or edit the application EAR file.
    For example, to change attributes of an existing application, click File-> Open then select the the EAR file.
    In the navigation pane, select the message-driven bean instance; for example, expand ejb_module_instance-> Message-driven beans then select the bean instance.
    A property dialog notebook for the message-driven bean is displayed in the property pane.
    Specify general deployment properties.
    In the property pane, select the General tab.
    Specify the following properties:
    Transaction type
    Whether the message bean manages its own transactions or the container manages transactions on behalf of the bean. All messages retrieved from a specific destination have the same transactional behavior. To enable the transactional behavior that you want, you must configure the JMS destination with the same transactional behavior as you configure for the message bean.
    Bean
    The message bean manages its own transactions
    Container
    The container manages transactions on behalf of the bean
    Specify advanced deployment properties.
    In the property pane, select the Advanced tab.
    Specify the following properties:
    Message selector
    The JMS message selector to be used to determine which messages the message bean receives; for example:
    JMSType='car' AND color='blue' AND weight>2500
    The selector string can refer to fields in the JMS message header and fields in the message properties. Message selectors cannot reference message body values.

    Acknowledge mode
    How the session acknowledges any messages it receives.
    This property applies only to message-driven beans that uses bean-managed transaction demarcation (Transaction type is set to Bean).

    Auto Acknowledge
    The session automatically acknowledges a message when it has either successfully returned from a call to receive, or the message listener it has called to process the message successfully returns.
    Dups OK Acknowledge
    The session lazily acknowledges the delivery of messages. This is likely to result in the delivery of some duplicate messages if JMS fails, so it should be used only by consumers that are tolerant of duplicate messages.
    As defined in the EJB specification, clients cannot use using Message.acknowledge() to acknowledge messages. If a value of CLIENT_ACKNOWLEDGE is passed on the createxxxSession call, then messages are automatically acknowledged by the application server and Message.acknowledge() is not used.

    Destination type
    Whether the message bean uses a queue or topic destination.
    Queue
    The message bean uses a queue destination.
    Topic
    The message bean uses a topic destination.
    Subscription durability
    Whether a JMS topic subscription is durable or non-durable.
    Durable
    A subscriber registers a durable subscription with a unique identity that is retained by JMS. Subsequent subscriber objects with the same identity resume the subscription in the state it was left in by the earlier subscriber. If there is no active subscriber for a durable subscription, JMS retains the subscription's messages until they are received by the subscription or until they expire.
    Nondurable
    Non-durable subscriptions last for the lifetime of their subscriber object. This means that a client sees the messages published on a topic only while its subscriber is active. If the subscriber is not active, the client is missing messages published on its topic.
    A non-durable subscriber can only be used in the same transactional context (for example, a global transaction or an unspecified transaction context) that existed when the subscriber was created. For more information about this context restriction, see The effect of transaction context on non-durable subscribers.

    Specify bindings deployment properties.
    In the property pane, select the Bindings tab.
    Specify the following property:
    Listener port name
    The name of the listener port for this message-driven bean.
    To apply the changes and close the Application Assembly Tool, click OK. Otherwise, to apply the values but keep the property dialog open for additional edits, click Apply.
    (Optional) To see changes reflected in your application, regenerate deployment code and reinstall the deployable archive.

    Use the WebSphere administrative console to install the application
    This stage is a standard WebSphere Application Server task, as described in Installing a new application.

    When you install the application, you are prompted to specify the name of the listener port that the application is to use for late responses. Select the listener port, then click OK.
  5. IBM InfoCenter for WAS 5.0[ Go to top ]

    Thanks a lot sheng for your detailed reply,

    Couldn't have asked for any thing better than that.

    many thanks again.
    Ravi
  6. weblogic and Mqseries[ Go to top ]

    Can i get the details on the same as mentioned in your message.