Ticket interface

This interface represents a correlation object that ties an asynchronous service request and response together.

Purpose

Use this interface to provide communication between an asynchronous service and a client. When the service completes processing a client request, it uses the ticket to contact the client with the response through the serviceCallback interface.

A ticket is long lived, can be persisted and reused across threads and processes. A ticket also implements the equals and hashCode methods, which allow it to be used as a key.

Examples

This example shows the StockQuoteSync service implementing a ticket interface for getQuoteAsync and getQuoteResponse.
public interface StockQuoteAsync {
	
	// deferred response
	public Ticket getQuoteAsync(String symbol);
	public float getQuoteResponse(Ticket ticket, long timeout);

	// callback
	public Ticket getQuoteAsync(String symbol, StockQuoteCallback callback);
}
This example shows the client invoking the StockQuoteAsync service and then requesting the response.
StockQuoteAsync sQ =  (StockQuoteAsync)serviceManager.locateService(“stockQuote");
Ticket ticket = stockQuote.getQuoteAsync("IBM");

	// do something else

float quote = stockQuote.getQuoteResponse(ticket, Service.WAIT);
Related information
Interface Ticket API

Terms of use |

Last updated: Thu Apr 27 15:50:14 2006

(c) Copyright IBM Corporation 2006.
This information center is powered by Eclipse technology (http://www.eclipse.org)