Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7026407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:06:48+00:00 2026-05-28T00:06:48+00:00

Got a problem with selecting message from topic by message id. Here’s the boiled

  • 0

Got a problem with selecting message from topic by message id.
Here’s the boiled down code:

//publish message
connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); 
//or external broker: tcp://localhost:61616

con = connectionFactory.createConnection();
con.setClientID("foo");
con.start();
session = connection.createSession(true, Session.SESSION_TRANSACTED);
topic = session.createTopic("topic_name");
producer = session.createProducer(topic);
//create text message
producer.send(message);
messageId = message.getJMSMessageID();
session.commit();
//close all stuff

//get message by id (the same VM split second after publishing)
//get connection the same way as for publishing
session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
topic = session.createTopic("topic_name");
consumer = session.createDurableSubscriber(topic, "SUBS1", "JMSMessageID='messageId'", false);
//here we get stuck though the message IS there
msg = consumer.receive(); //receiveNoWait gives null

moreover even if I provide selector which is always true
e.g. “1=1” or empty one : “”, null

it does not fetch messages too despite it is durable subscriber.

On the other hand if I post something after consumer with alsways true selector was created it does fetch this message.

but code like this DOES fetch all my messages including the one with id i’ve been looking for

consumer = session.createDurableSubscriber(topic, "SUBS1");
while (msg != null) {
    msg = consumer.receive();
}

It looks to me that DurableSubscriber with selector ignores existing messages. Though I didn’t find anything like that in the jms 1.1 spec

So far I tried only ActiveMQ 5.5.1 as JMS provider

The question is am I doing something wrong or it is a bug?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:06:49+00:00Added an answer on May 28, 2026 at 12:06 am

    If you connect to a topic “after” a message was sent to it (and you do) then there is no way you can receive the message. Unless durable subscriber is used and it had been created “before” the message was sent to the topic.

    A message is stored in the topic only for active non durable subscribers and for durable subscribers that are already created. Even if they are offline.

    You can create durable subscriber with selector that uses particular correlationId and then set that correlationId to your message and send it to the topic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I got problem with scroll on my grid. Here is the code (nothing
i got problem with my code and hopefully someone able to figure it out.
I got a problem with this linq query: from PersistedFileInfo fi in m_Database from
I have a problem selecting 6 random friends This is the query I've got
I've got problem with connecting to MySQL database on my freshly installed Windows 7
Got a problem with ADOMD.NET 8.0, SQL2008 and our app. It isn't giving us
Got a problem with a query I'm trying to write. I have a table
Got a problem with ComponentListener. I'm using it to check if a certain component
I got a problem like this (this is html/css menu): Eshop | Another eshop
I got one problem at my exam for subject Principal of Programming Language. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.