Atmosphere/atmosphere — Issue #149: JMSBroadcaster JMS Session is null, every time
Author: mattnathan
Created: 2012-01-17 15:36:26+00:00
State: open

In JMSBroadcaster the outgoingBroadcast method checks to see if the session object has been set. If it is null it throws an exception. Unfortunately this is always the case because as far as I can tell the configure method is never called (the only place the session is set). This causes the following exception to be thrown every time a message is received.

```
2012-01-17 15:19:09,517 [ActiveMQ Session Task] ERROR org.apache.activemq.ActiveMQMessageConsumer - ID:localhost.localdomain-57073-1326813541941-0:0:1:1 Exception while processing message: java.lang.IllegalStateException: JMS Session is null
java.lang.IllegalStateException: JMS Session is null
at org.atmosphere.plugin.jms.JMSBroadcaster.outgoingBroadcast(JMSBroadcaster.java:214)
at org.atmosphere.util.AbstractBroadcasterProxy.broadcast(AbstractBroadcasterProxy.java:145)
at org.atmosphere.plugin.jms.JMSFilter$1.onMessage(JMSFilter.java:171)
at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1088)
at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:127)
at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:197)
at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
```

The Class I'm using to test with is:

```java
package test;

import org.atmosphere.annotation.Broadcast;
import org.atmosphere.annotation.Cluster;
import org.atmosphere.annotation.Suspend;
import org.atmosphere.cpr.Broadcaster;
import org.atmosphere.jersey.Broadcastable;
import org.atmosphere.plugin.jms.JMSFilter;

import javax.ws.rs.*;

/**
* Servlet that will listen for subscription requests and publish any messages that are sent via a JMS queue.
*/
@Path("/{topic}")
public class ServerPushServlet {
@PathParam("topic")
private Broadcaster topic;

@GET
@Suspend(resumeOnBroadcast = true, outputComments = true)
public Broadcastable subscribe() {
return new Broadcastable(topic);
}

@POST
@Broadcast
@Produces("application/xml;charset=UTF-8")
@Cluster(name = "chat", value = JMSFilter.class)
public Broadcastable broadcast(String content) {
return new Broadcastable(content, "", topic);
}
}
```
I'm using atmosphere 0.8.3