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);

Parent topic: Programming interfaces

Related reference
Component interface
DataFactory interface
EndPointReference interface
EndPointReferenceFactory interface
Service exceptions
InterfaceType interface
Service interface
ServiceCallback interface
ServiceImplAsync interface
ServiceImplSync interface
ServiceManager class

Related information
Interface Ticket API


Terms of use |

Last updated: Tue Sep 20 03:22:37 2005

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