BAM client and server
After we realized BAM can be used as a queueing system replacing JMS, we looked at the BAM client and service configuration to simplify it for queueing, and at the same time fix some of the problems associated with JMS messaging. The new BAM configuration is fairly simple. A <bam-service> configures the service, just like Resin’s <ejb-message-bean>. A BamClient class creates a new client.
- Create a SimpleBamService to handle the queued messages
- Configure the <bam-service>
- Send messages using a BamClient
So sending a message looks like the following. “my-message” can be any serializable object, and
“service@localhost” is the JID name of the service.
BamClient client = new BamClient();
client.message("service@localhost", "my-message");
The service itself implements com.caucho.bam.BamService.
import com.caucho.bam.SimpleBamService;
public class MyService {
public void message(String to, String from, java.io.Serializable data)
{
System.out.println("DATA: " + data);
}
}
And the configuration looks like
<bam-service name="service@localhost" class="example.MyService"/>
</web-app>
