StreamBase custom adapter sendOutput method does not send a tuple

StreamBase custom adapter sendOutput method does not send a tuple

book

Article ID: KB0074916

calendar_today

Updated On:

Products Versions
TIBCO Streaming -

Description

Trying to schedule the fillAndOutputTuple method of the adapter to run at a specific time. When passing the adapter instance to a scheduler context and when the scheduler job triggers, sendOutput executes with no exception but does not emit any tuples out of the adapter.

Issue/Introduction

Emitting a tuple requires the use of a Managed Thread in custom StreamBase operators and adapters.

Resolution

The class Operator provides "managed threads", which are threads that run concurrently with the application but which can synchronize with its overall state changes. These threads are started, suspended, resumed and shut down with the application. Managed threads are registered with an Operator using the method registerRunnable(). This is useful for input adapters which typically have to respond to external events asynchronously with the application. Managed threads can call sendOutput() at any time.

This means that sendOutput() behavior is not defined when called from an unmanaged thread, which is a thread which was not started by registerRunnable(). The preferred approach is to establish a java.util.concurrent.BlockingQueue which the registered thread waits on. When any thread (unmanaged or managed) inserts into the queue then the registered thread unblocks and does what it needs to do. This is most often used when a payload is generated in an unmanaged thread and needs to be delivered to a managed thread for further processing. If there is no payload, then a wait() and notify() may be used instead instead of a queue.

Additional Information

JAVA API Guide for class "com.streambase.sb.operator.Operator"