public interface TransactedSessionHandle extends Handle
Allocator.newTransactedSessionHandle()
Before the TransactedSessionHandle
can be used, a native transacted session must be
created on a native non-transacted session with
SessionHandle.createTransactedSessionForHandle()
.
Client applications can create one or more transacted sessions within a non-transacted session. The lifecycle of a transacted session is bounded by the lifecycle of its non-transacted parent session. In other words, when a session is destroyed/disposed, all transacted sessions created within this session will be destroyed/disposed too. A transacted session can have at most one publisher flow and zero or many subscriber flows. All messages sent/received by a transacted session must have a guaranteed delivery mode, there is no support for direct transport messages.
There are two types of Message Dispatchers, which client applications can choose when a Transacted Session is created.
TransactedSessionHandle.createFlowForHandle(com.solacesystems.solclientj.core.handle.FlowHandle, java.lang.String[], com.solacesystems.solclientj.core.resource.Endpoint, com.solacesystems.solclientj.core.resource.Subscription, com.solacesystems.solclientj.core.event.MessageCallback, com.solacesystems.solclientj.core.event.FlowEventCallback)
),
the method FlowHandle.ack(long)
returns
SolEnum.ReturnCode.OK
and no operation (NOP) is performed.
message callback
is provided when a transacted consumer Flow is created, messages received on the flow
are dispatched to the callbacks just as on non-transacted Flows, but in the context of an
internal Contex-bound or TransactedSession-bound Message Dispatcher thread.
message callback
,
messages received on Flows are queued internally. Applications must call function
FlowHandle.receive(com.solacesystems.solclientj.core.handle.MessageHandle, int)
directly to retrieve messages from those internal queues.
TransactedSessionHandle.PROPERTIES.HAS_PUBLISHER
must be enabled when the Transacted
Session is created.
The main differences between publishing guaranteed messages from a Transacted Session and from a Session are:
TransactedSessionHandle.PROPERTIES.PUB_WINDOW_SIZE
.
When connecting to PubSub+ brokers 9.8.1 or later, this property allows the application to reduce the outstanding
window if there are memory/resource restrictions that preclude the larger window. For example, if the
application is only publishing large or max size messages (30mb), it may wish to restrict the number in flight.
message callback
,
invoke commit/rollback/sendMsg only from the message callback
(i.e. in the context of an internal Message Dispatcher thread).
FlowHandle.receive(com.solacesystems.solclientj.core.handle.MessageHandle, int)
directly,
TransactedSessionHandle.commit()
/TransactedSessionHandle.rollback()
/TransactedSessionHandle.send(com.solacesystems.solclientj.core.handle.MessageHandle)
/FlowHandle.receive(com.solacesystems.solclientj.core.handle.MessageHandle, int)
functions must be called in the context of the same application thread.
Modifier and Type | Interface and Description |
---|---|
static class |
TransactedSessionHandle.PROPERTIES
Defines the property names used to create a transacted session handle
|
Modifier and Type | Method and Description |
---|---|
int |
commit()
Commit the active transaction of a specified Transacted Session.
|
int |
createFlowForHandle(FlowHandle in_out_flowHandle,
java.lang.String[] flowProperties,
Endpoint endpoint,
Subscription subscription,
MessageCallback messageCallback,
FlowEventCallback flowEventCallback)
Create a transacted consumer Flow within a specified Transacted Session.
|
SessionHandle |
getSession()
Returns the associated SessionHandle
|
java.lang.String |
getSessionName() |
int |
rollback()
Rollback the active transaction of a specified Transacted Session.
|
int |
send(MessageHandle msg)
Sends a Guaranteed Delivery message on the specified Transacted Session.
|
int commit() throws SolclientException
SolEnum.ReturnCode.OK
on success.SolEnum.ReturnCode.ROLLBACK
if a rollback
is received and the Transacted Session is still active.SolEnum.ReturnCode.NOT_READY
if the underlying transport is not connectedSolclientException
- When commit() throws an exception, the status of the outstanding commit request cannot be
determined. The commit may have succeeded on the message-router before the response was lost.
Or the commit request may have failed (roll back). Applications that treat the failure
as a rollback must allow for duplicate transactions.int rollback() throws SolclientException
SolEnum.ReturnCode.OK
on success.SolEnum.ReturnCode.NOT_READY
if the underlying transport is not connectedSolclientException
int createFlowForHandle(FlowHandle in_out_flowHandle, java.lang.String[] flowProperties, Endpoint endpoint, Subscription subscription, MessageCallback messageCallback, FlowEventCallback flowEventCallback) throws SolclientException
MessageCallback
is provided, messages received on the flow are dispatched
to the callback in a context of a Message Dispatcher thread. If there is no MessageCallback
(i.e. messageCallback parameter is NULL), messages received on the Flow are queued internally.
Applications must call FlowHandle.receive(com.solacesystems.solclientj.core.handle.MessageHandle, int)
directly to retrieve the queued messages.
Unlike non-transacted Flows, events and messages received on a transacted Flow are delivered
in the context of two different threads. Events are still delivered in a context of
the context thread, but messages are dispatched to the Flow MessageCallback
in the context of a Message Dispatcher thread or are retrieved by
calling FlowHandle.receive(com.solacesystems.solclientj.core.handle.MessageHandle, int)
from the context of an application thread.
The following flow properties are not supported by transacted Flows:
in_out_flowHandle
- flowProperties
- FlowHandle.PROPERTIES
endpoint
- Description of the endpoint on the appliance.subscription
- Optional subscription to add if the endpoint is a topic endpoint.messageCallback
- Optional MessageCallback
for incoming messages.flowEventCallback
- FlowEventCallback
SolEnum.ReturnCode
SolclientException
java.lang.String getSessionName() throws SolclientException
SolclientException
SessionHandle getSession() throws SolclientException
SolclientException
int send(MessageHandle msg) throws SolclientException
MessageHandle
. The application should first
allocate a
MessageHandle
, then use the methods defined on that object to build the message to send.
A successful TransactedSessionHandle.commit()
acknowledges published messages delivered to the Solace
messaging appliance.msg
- MessageHandle
SolEnum.ReturnCode.OK
SolEnum.ReturnCode.NOT_READY
if the underlying transport is not connectedSolclientException
Copyright 2004-2024 Solace Corporation. All rights reserved.