Skip to main content

Glassfish4, web and Java EE JMS

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
josealvarezdelara
Offline
Joined: 2008-12-26

Hi,

I am trying a JMS webapp using Glassfish4 as the app server and I am facing troubles on the execution of the following method,

public void getMessage() {
try {
JMSConsumer receiver = context.createConsumer(topic);
String text = receiver.receiveBody(String.class);

if (text != null) {
myList.add(text);
} else {
FacesMessage facesMessage =
new FacesMessage("No message received after 1 second");
FacesContext.getCurrentInstance().addMessage(null, facesMessage);
}

} catch (Throwable t) {
logger.log(Level.SEVERE,
"ReceiverBean.receiveMessages: Exception: {0}",
t.toString());
}
}

This method is in a managed bean nemad ReceiverBean. The process is I send a message to the topic from the managed bean SenderBean and the receiver.xhtml file is loaded for calling the method from a commandLink. But it does not happen anything except the page stay waiting for this method to be resolved that ever occur.

Well the reasson of my post is to know how can I apply this method in a JSF webapp.

Kind regards,
Jose

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
josealvarezdelara
Offline
Joined: 2008-12-26

Just changing the consumer,
JMSConsumer receiver = context.createConsumer(topic);

for a SharedDurableConsumer that no needs a clientID,
JMSConsumer receiver = context.createSharedDurableConsumer(topic, "MakeItLast");

It is enough to workaround the issue.

Regards,
jose