EPCIS QueryCallback

Fosstrak EPCIS – User Guide

 

How to Use the Query Callback Interface

After a subscription has been registered, the EPCIS repository will deliver results of query executions through the Query Callback Interface. The query results will be deliverd as HTTP POST requests to the URL specified by the dest parameter in the query subscription. It is the client’s responsibility to listen for the response at the given URL.

If you want to have a look at the query result responses without coding anything, you can use a TCP monitor tool, such as Apache TCPMon. This tool can be configured as a listener for a given port and allows you to monitor incoming messages.

If you need to access the query results from whithin your code, you can take advantage of the QueryCallbackListener class from the epcis-commons.jar library. This class implements a very simple HTTP server that listens for requests to a given URL. It catches any incoming POST data and delivers it to an application upon request. The listener can be used as follows:

QueryCallbackListener listener = QueryCallbackListener.getInstance();
if (!listener.isRunning()) {
    listener.start();
}
synchronized (listener) {
    try {
        listener.wait(timeout);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
String response = listener.fetchResponse();

In this code, the wait() method waits until either the listener receives a response or the specified timeout has elapsed.

 

Advertisement

Leave a Comment

No comments yet.

Comments RSS TrackBack Identifier URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.