Using General Callbacks
The following example contains an excerpt from a sample that shows the use of the BrokerClient.registerCallback method to register a general callback object.
class subscribe2
{
. . .
static int num_to_receive = 10;
public static void main(String args[])
{
. . .
SampleCallback2 sample_callback =
new SampleCallback2(num_to_receive);
/* Create a client */
. . .
/* Check if can subscribe */
. . .
/* Register callback */
try {
c.registerCallback(sample_callback,null);
} catch (BrokerException ex) {
System.out.println("Error on registering callback\n"+ex);
return;
}
/* Open the subscription */
. . .
/* Do main loop */
try {
BrokerClient.mainLoop();
} catch (BrokerException ex) {
System.out.println("Error on dispatch\n"+ex);
return;
}
. . .