JMS Queue - 2 Consumers from single Queue

Hi,
I have a scenario like, there is a single which has records. Of which some records need to be send to 1 application and some records need to be sent to anothere appln.
So, there are two consumers for this Queue.
How to implement this in SOA?
Is selecting the data based on a flag possible?
Thanks,
Priya

You can use Message Selectors for this. Please refer the below link
SOA 11g- Message Selector Property in JMS Adapter - Oracle Fusion Middleware Blog

Similar Messages

  • Single queue: concurrent processing of messages in multiple consumers

    Hi,
    I am new to jms . The goal is to  process messages concurrently from a queue in an asynchronous listener's onMessage method  by attaching a listener instance to multiple consumer's with each consumer using its own session and running in a separate thread, that way the messages are passed on to the different consumers for concurrent processing. 
    1) Is it ossible to process messsages concurrently from a single queue by creating multiple consumers ?
    2)  I came up with the below code, but would like to get your thoughts on whether the below code looks correct for what I want to accomplish.  
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Properties;
    import javax.jms.Connection;
    import javax.jms.ConnectionFactory;
    import javax.jms.Destination;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageListener;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import com.walmart.platform.jms.client.JMSConnectionFactory;
    public class QueueConsumer implements Runnable, MessageListener {
      public static void main(String[] args) {
       // Create an instance of the client
        QueueConsumer consumer1 = new QueueConsumer();
        QueueConsumer consumer2 = new QueueConsumer();
        try {
        consumer1.init("oms","US.Q.CHECKOUT-ORDER.1.0.JSON");   //US.Q.CHECKOUT-ORDER.1.0.JSON   is the queue name
        consumer2.init("oms","US.Q.CHECKOUT-ORDER.1.0.JSON");
        }catch( JMSException ex ){
        ex.printStackTrace();
        System.exit(-1);
        // Start the client running
        Thread newThread1 = new Thread(consumer1);
        Thread newThread2 = new Thread(consumer1);
        newThread1.start();newThread2.start();
        InputStreamReader aISR = new InputStreamReader(System.in);
              char aAnswer = ' ';
              do {
                  try {
      aAnswer = (char) aISR.read();
    catch (IOException e)
      // TODO Auto-generated catch block
      e.printStackTrace();
    } while ((aAnswer != 'q') && (aAnswer != 'Q'));
              newThread1.interrupt();
              newThread2.interrupt();
              try {
      newThread1.join();newThread2.join();
      } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
              System.out
      .println("--------------------exiting main thread------------------------"+Thread.currentThread().getId());
            System.exit(0);
    // values will be read from a resource properties file
    private static String connectionFactoryName = null;
    private static String queueName = null;
    // thread safe object ref
      private static ConnectionFactory qcf = null;
      private static Connection queueConnection = null;
    // not thread safe
      private Session ses = null;
      private Destination queue = null;
      private MessageConsumer msgConsumer = null;
      public static final Logger logger = LoggerFactory
      .getLogger(QueueConsumer.class);
      public QueueConsumer() {
      super();
      public void onMessage(Message msg) {
      if (msg instanceof TextMessage) {
      try {
      System.out
      .println("listener is "+Thread.currentThread().getId()+"--------------------Message recieved from queue is ------------------------"
      + ((TextMessage) msg).getJMSMessageID());
      } catch (JMSException ex) {
      ex.printStackTrace();
      public void run() {
      // Start listening
      try {
      queueConnection.start();
      } catch (JMSException e) {
      e.printStackTrace();
      System.exit(-1);
      while (!Thread.currentThread().isInterrupted()) {
      synchronized (this) {
      try {
      wait();
      } catch (InterruptedException ex) {
      break;
      * This method is called to set up and initialize the necessary Session,
      * destination and message listener
      * @param queue2
      * @param factoryName
      public void init(String factoryName, String queue2) throws JMSException {
      try {
      qcf = new JMSConnectionFactory(factoryName);
      /* create the connection */
      queueConnection = qcf.createConnection();
      * Create a session that is non-transacted and is client
      * acknowledged
      ses = queueConnection.createSession(false,
      Session.CLIENT_ACKNOWLEDGE);
      queue = ses.createQueue(queue2);
      logger.info("Subscribing to destination: " + queue2);
      msgConsumer = ses.createConsumer(queue);
      /* set the listener  */
      msgConsumer.setMessageListener(this);
      System.out.println("Listening on queue " +queue2);
      } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
      private static void setConnectionFactoryName(String name) {
      connectionFactoryName = name;
      private static String getQueueName() {
      return queueName;
      private static void setQueueName(String name) {
      queueName = name;

    Hi Mark,
    if the messages are sent with quality of service EO (=exactly once) you can add queues.
    From documentation:
    Netweaver XI -> Runtime -> Processing xml messages -> Queues for asynchronous message processing
    ...For incoming messages you set the parameter EO_INBOUND_PARALLEL from the Tuning category.
    If more than one message is sent to the same receiver, use the configuration parameter EO_OUTBOUND_PARALLEL of the Tuning category to process messages simultaneously in different queues.
    Transaction: SXMB_ADM
    Regards
    Holger

  • Consumers for distributed queues -- writing the JMS API

    Hi,
    I have Created a cluster MS_01 and MS_02.
    JmsServer-MS01 for MS_01 and JmsServer-MS02 for MS_02.
    Also have create a distributed queue called DistributedQueue-0 and a distributed connection factory called ConnectionFactory-0.
    I have been successfully able to loadbalance sending of messages using the cluster address.
    When i try to consume messages the consumers gets pinned to a MS_01. (As expected)
    I am looking for ways where in using JMS API i can read messages from both the manages instances.
    Appreciate any help.
    thanking you all in advance.
    Regards
    Girish Subbaramu.

    Hi,
    For consuming messages from a distributed queue, by far the best option is to use a WebLogic MDB, which has internal code designed to work well with WebLogic distributed destinations. When a distributed queue runs in the same cluster as the MDB, the MDB service will ensure that there's an MDB deployment instance that is locally servicing each queue member -- even when the queue members migrate between servers, or when they are added or removed due to configuration changes. When the MDB is communicating with a distributed queue in a remote cluster, an MDB running on a single server will automatically set up consumers for each remote member and will dynamically react to member up/down add/remove events.
    If you must use a straight javax.jms client, then I think there are two basic options. The first option is to ensure that that there are more than enough consumers to provide full coverage, and periodically close and re-open the consumers. The periodic close and re-open forces the consumers to load-balance again, and therefore helps handle the case when new destination members become available after the consumers have all attached. The second option is to create consumers directly on each member rather than on the distributed queues logical name (each member has a unique name that's advertised in JNDI).
    Hope this helps,
    Tom

  • Routing JMS message from same queue to different channels.

    From a given adapter module, is there a way of calling different communication channels?
    The scenario: The sender of the data is JMS. One single queue contains desperate text format. Based on the content of the first 4 characters , PI has to parse it differently in its own corresponding MT. The target IDoc structure remains the same. I have multiple messageTransformBeans set up, one for each MT assuming that the data would arrive in different JMS queues. However since the data is now all heaped on to a single queue, the challenge of routing the data now lies in SAP PI.
    HowTo - Send Test Messages to the Adapter Engine (to an Integrated Configuration) - This solution does send message directly to the IE (using 7,1), but not to the adapter engine where the messageTransformBeans exist.
    Any solid pointers in the direction will be really helpful.
    Regards,
    Keerti

    Hi,
    you can go for end to end testing.
    if jms not available use file adapter in the sender side and fetch the text file and test it.
    Regards,
    Muni

  • How can a JMS adapter be configured in BPEL to consume messages from multiple queues ?

    How can a JMS adapter be configured in BPEL to consume messages from multiple queues ?

    If you want to use JMS with AQ as datastore then there is some configuration you need to do to enable this. This is outside SOA Suite per sa, e.g. no adapter required.
    If you want to connect to the AQ direct then use the AQ adapter.
    this blog may be of some help understand the configuration
    http://biemond.blogspot.com/2008/01/oracle-jms-with-esb-and-bpel.html
    cheers
    James

  • Consumers from for wlsb.internal.transport.task.queue.ftp Queue on OSB

    Hi All,
    Can anyone tell me where do I get the Consumers for Queue:
    wlsb.internal.transport.task.queue.ftp_auto_1
    wlsb.internal.transport.task.queue.ftp_auto_2
    I have consumers in my 1st Queue but not in my 2nd Queue for any of the Internal Transport Queues.
    Please let me know how do I solve this Issue.
    Thanks !

    You might be better of asking this in the SOA/OSB forum. Also please add version, OS etc.
    The ftp poller from OSB is always targeted to exactly one server, but at least in theory both servers should pick up the messages from the distributed Q.
    What behaviour exactly are you seeing? Does it relate to the ftp poller target?
    best wishes!
    Blog: Oracle Fusion Middleware and Cloud Computing

  • Publishing message to JMS Queue on Weblogic from OSB proxy service

    Hi,
    1. I have created a JMS module: testModule and a JMS queue: testQueue in the weblogic admin console.
    2. Created a business service with the above queue as endpoint.
    3. Created a proxy service which publishes the message to the queue using the business service. I have used Publish activity to publish the message to the business service.
    When i run the proxy service with the request message, then, no error is coming but, in the admin console when i click on JMS module->testModule->testQueue->Monitoring tab, i see nothing. There are no entries in the table so, how can i check if the message is properly published to the queue or not.
    The queue is not listened by any service for consuming the messages.
    Kindly help me in figuring out this issue.
    Thanks in advance.

    If the destination was a topic, the behavior would be expected. Messages only stays on a topic and are delivered to consumers if there are consumers or durable subscribers.
    Did you check the server logs and see if there are any exceptions or warnings?
    You can also turn on jms debugging by adding the following to your server startup script.
    -Dweblogic.debug.DebugJMSFrontEnd=true
    -Dweblogic.debug.DebugJMSBackEnd=true
    The debugging messages wiill show up in the server log.

  • Problems enqueuing a CLOB on JMS_TEXT queue and dequeue from JMS

    Hi, I have a PL/SQL procedure that enqueues in a JMS_TEXT queue a CLOB, and a MDB in J2EE reading messages from that queue. The problem is that text from dequeued messages appears as null in java, but if I send messages to the queue using Varchar2 I get the correct message. What's wrong?? Thanks.

    Hi,
    I encountered the same problem. The fix was to use a more recent aqapi13.jar:
    if last modification date is 22th April 2002, then it does not read CLOB content.
    if last modification date is 14th October 2004, then it does read CLOB content.
    Note I am using Oracle 9i Release 2.

  • Cases where messages are not being consumed from a queue

    MQ 4.0
    I have a cluster of 3 brokers. Java clients use RANDOMIZE to connect to the cluster of brokers. Message selectors are not used. My consumers are all synchronous, and connection.start() is called prior to calling MessageConsumer.receive().
    What I have seen on random occassions are messages not being consumed from the queue. The problem seems to be sporadic.
    I was thinking that the reason it is sporadic is because of the RANDOMIZE configuration of the client connetion / object-store.
    That is, there is a possibility for the following to happen:
    1) There were messages produced on a queue on broker A, but before these messages were consumed, all the consumers have been shutdown. Thus, the messages on queue stayed on broker A .... and have not been copied / clustered to the other brokers in the cluster ( As per online documentation, a queue is "copied" to other brokers only when there is a consumer for that queue on the other brokers ).
    2) Then the client applications started up produced and consumers again. This time, the producers were all connected to broker B, and all consumers for the queue were also connected to broker B.
    3) Because there are no other consumers for the queue on the other brokers, the messages in the queue on broker A are never consumed.
    Can someone confirm that this is a possibility ?

    Well ... it does seem to be the case.
    I changed the object-store so that instead of using RANDOMIZE for imqAddressListBehavior, it uses PRIORITY. Therefore, all clients ( producers and consumers ) will connect to only 1 broker out of the 3 in the cluster.
    After restarting all JMS clients with the new imqAddressListBehavior, there were messages in various queues in the other brokers that were not being consumed, because there are no longer any consumers on any of the other brokers.
    All the messages in that broker that all JMS clients connect to are being consumed ...
    Except for about 6 messages that stays in the queue for whatever reason. All consumers receiving with receive( 10000 ), and after consuming all messages above the 6, it returns without any more messages in the queue.
    Well ... so much for cluster of brokers. I'll have to think of an alternative.

  • OSB 11g: Business Service not getting reply back from distributed queue

    Here is the scenario:
    OSB Domain A has a Business service that does a JMS send to a distributed JMS queue hosted on another WLS domain.
    It expects a response from a distributed queue sitting on this same remote WLS domain.
    The remote WLS domain is configured as a Foreign JNDI Provider in the OSB Domain with the request and response queues defined. Testing this business service, we see that messages are being posted to the remote request queue fine, and that the message are being picked up and processed. The response was sent to the response queue, but the message just sits there, the OSB business service did not pick it up. I can see 16 active Consumers on the response queue, presumably from the OSB business service?
    Using CorrelationID.
    URI for request/response queues are using the locally defined JNDI name for the queues and connection factories from the Foreign JNDI Provider definition:
    - URI for request queue: jms:///[RemoteXAConnectionFactoryX]/[LocalJNDINameForRequestQueue]
    - URI for response queue: jms:///[RemoteXAConnectionFactoryX]/[LocalJNDINameForResponseQueue]
    Completely stumped at the moment...anybody has any ideas?
    Thanks,
    Melvin

    Hi,
    I am also facing the similar kind of issue as below. After placing the message in to request Queue, I need that message Id as response to that Business service. Please provide the solution for the below issue. Thanks in advance.
    Thanks,
    bharath.

  • Removing superseded messages from the queue

    Does JSMQ provide any way for a producer to remove a message from the queue which it queued some time ago but which it no longer wishes to send?
    I am investigating the use of JSMQ in a military battlemap application connecting nodes over low bandwidth/unreliable connections. The reason we want to be able to remove messages is as follows: Say a producer sends a low priority message to the queue regarding a unit's position. Later on the same producer sends an update regarding the same unit to the queue. If the first message is still present in the queue (ie has not been sent yet) then we want the producer to be able to remove it as it is now superseded by the new message and we don't want to waste bandwidth sending the old message first.
    I know we can set an expiry time on messages, but this doesn't really solve our problem. We want the original message to stay in the queue indefinately (until it is read by the consumer) unless it is superseded by a new message in which case we want to remove it.
    Thanks
    Roger

    Hi Roger,
    JMS does not support the removal of messages from a queue
    as you described. I can't think of a way to not deliver the old
    message once it was already sent.
    Alternatives I can think of:
    - Adjust the interval at which the consumer reads the messages
    off the queue and/or the number of messages that are read;
    so that the consumer will see the old and new messages
    and can decide which one to use. This does not address the
    bandwidth issue but allows the consumer to behave smarter.
    - Similar to above, but on the producer side. The producer waits
    for some interval before sending a message, in case an
    updated position of a unit arrives at the producer. This might not
    be good if a consumer needs to know the location of a unit as
    soon as it is available.
    - Use a topic instead of a queue. When using queues, old
    messages (containing old positions) sent to a queue are kept
    until the consumer reads it. With topics, if no consumers are
    around, the message is tossed. However, if you really need old
    messages to lie around (e.g. need to know last position of
    unit), this won't suit your needs.
    Sorry I don't have a straight answer for you, hope this helps
    somewhat.
    -i
    http://wwws.sun.com/software/products/message_queue/index.html

  • Delta package not fetching all records from Delta queue in r/3

    Hello,
    I have loaded Goods Movement Data using 2LIS_03_BF datasource into my BI system.
    The Delta has been initialized and everyday the delta is being moved from r/3.
    I observed that when I execute my delta package not all delta records are fetched into PSA from r/3.
    For Ex: Before starting my delta package I checked in SMQ1 of my R/3 system and see that there are around 1000 records.On executing the delta package I see that the record count is reduced from 1000 to 400 in SMQ1.On executing the delta package again I get the remaining 400 records into my PSA.
    Shouldn't the delta package get all records from the queue on single execution??
    Is there some setting to define the nr of records to be loaded?
    I'm confused with this behaviour.Please help me understand this behaviour.
    Thank You.

    Hello,
          First thing: the data is not transferred from the SMQ1 queue, rather the data is transfered to BW from the RSA7 Delta queue. You need to check the number of records present in the RSA7 queue.
    Since SMQ1 is involved, i think you are using the unserialized V3 update method. In this method, when data is first written to the application tables, it is first transferred to the SMQ1 update queue,then via a job to the LBWQ extractor queue and then to the RSA7 delta queue. So the number of entries that you see in the SMQ1 queue are not the number of entries that have to be transferred to BW but rather the records that are waiting to be transferred to the extractor queue in LBWQ. Similarly, in LBWQ, the number of entries displayed here are not the no of entries that are going to be transferred to BW, they are the no of entries that will be transferred to the delta queue RSA7 when the next v3 update job runs.
    If you want to check the number of records that will be transferred to BW, select the datasource in rsa7 and then click on the display data entries button.
    Hope this helps.
    Regards.

  • We need to open the connection each time you read a message from the queue?

    Hi
    I have a doubt regarding my queue read data that contains those I create a session and connection.
    Whenever I do this or you can create a connection and get all data from the queue and then close the connection and session
    eg. I have 1000 files in the queue and I read all files but without creating a session and a connection every time you get a single figure, this can be done?
    I read the 1000 files without having close the session or the connection
    thanks for the help.

    I answered myself.
    No need to open a connection and a session each to be read from a data queue to extract the entire contents of the queue with only one session and open a single connection.

  • Single Queue Vs Multiple Queues

    Hi,
    I am in the process of architecting some queues between remote databases. There are different document types being propagated from one queue to another, and they have different priorities. At the end queue there are multiple processes to dequeue and action the different document types.
    My question is, is it better to have one end queue for each process/document type ( ie multiple end point queues), or one single end point queue with all the documents in them regardless of the type?
    I know that it is possible to have the single queue end point, but is this the best option and why?
    Thanks,
    matt

    Hi Peter,
    What do you mean by different document type?Document content only is different. The payload will be the same. All the documents will be passed through as blobs. The payload will have a field to define the document content type.
    Do you intend to store different message types in the same source queue?At this stage we can go either way. If we have one single end point queue we will more than likely have one single source queue.
    If so what is the definition of the payload? The payload definition will be the same in all cases, both source and destination.
    What version of databases are you propagating between?10.2
    How many dequeueing processes will you have at the remote end?One program for each of the different document content type (invoices, remittance, etc.). Initially there will be 4, but this is likely to grow to 12 or more.
    Ultimately we expect around 10,000 documents per day to pass through the system.
    Thanks,
    Matt

  • Dequeued messages not deleted from one queue but other works

    Hi,
    I have a multiconsumer queue with two local subscribers.
    The messages go to the 'PROCESSED' state but do not get
    deleted from the queue table.
    As a test, I created another single consumer queue in a different andqueue table, but the oracle deleted the 'PROCESSED' messages as expected.
    In the multiconsumer queue, the messages are added by a trigger on the table. The enqueued messages varies from 100000 to 10000 per hour.
    aq_tm_processes = 5
    job_queue_processes=4
    What else can I do debug the problem?
    Is there any log file on the database server that I can
    look at any potential problem.
    I would appreicate any responses. This could very well
    be a newbie problem. I have not worked on advanced queues
    before and nor has anyone else in our system.
    Thanx,
    HB.

    I forgot to add that I am using default retention time
    and when I query user_queue the retention time is set to zero for the multiconsumer queue.

Maybe you are looking for

  • Network upgrade in small/medium business

    Hello, I have been asked by a friend to do an upgrade to his business network.  I would appreciate any help and suggestions. There are several things which need to be accomplished: Implement a VPN solution for remote access Increase bandwidth to supp

  • Exchange Server 2013 installation error at Step 10/15

    I try to install Exchange Server 2013 on a fresh install of Windows Server 2012. Windows Server 2012, have already install on it: AD CD DNS IIS Exchange 2013 Prerequisites for Win.Server 2012 like described here http://technet.microsoft.com/en-us/lib

  • Error 29 using final cut pro X ?

    How to burn a DVD in Final Cut Pro X ? I keep getting error code -29 .

  • Is there a way to turn my iPhone on if my lock button doesn't work?

    My lock button broke & I was wondering if there's is another way to turn my phone on ?

  • Ethernet cable issue.

    Hi all-- I recently acquired this G3 B&W 300, which I am trying to connect to my wired/wireless router via an ethernet cable. I have no Airport card in this machine. When I tried to set it up, Network Status in system prefs told me that "there is no