public class BrokerService
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_WAITTIME
The initial default wait time used in the sendReceive() method call and
all receive() method calls.
|
Constructor and Description |
---|
BrokerService(Broker broker,
java.lang.String serverAddr)
Creates a new BrokerService object.
|
BrokerService(Broker broker,
java.lang.String serverClass,
java.lang.String serverName,
java.lang.String serviceName)
Creates a new BrokerService object.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelallConversations()
Cancels all conversations for this service.
|
void |
deregister()
Deregisters a registered BrokerService object from the EntireX Broker.
|
void |
deregisterImmediate()
Deregisters a registered BrokerService object from the EntireX Broker.
|
void |
endallConversations()
Ends all conversations for this service.
|
Broker |
getBroker()
Returns the Broker object to which the service belongs.
|
java.lang.String |
getCharacterEncoding()
Gets the character encoding name or
null . |
java.lang.String |
getDefaultWaittime()
Returns the default wait time.
|
java.lang.String |
getEnvironment()
Returns the environment.
|
int |
getMaxReceiveLen()
Returns the current maximum receive length.
|
java.lang.String |
getServerClass()
Returns the server class.
|
java.lang.String |
getServerName()
Returns the server name.
|
java.lang.String |
getServiceName()
Returns the service name.
|
boolean |
isGeneric()
Returns an indication whether this is a generic service.
|
BrokerMessage |
receive()
Receives an incoming request or message.
|
BrokerMessage |
receive(java.lang.String wait)
Receives an incoming request or message.
|
BrokerMessage |
receiveAny()
Receives an incoming request or message.
|
BrokerAttachInfo |
receiveAttachInfo()
Receives for attach servers a notification about waiting clients.
|
BrokerMessage |
receiveOld()
Receives an incoming request or message.
|
void |
register()
Registers a BrokerService with the EntireX Broker.
|
void |
registerAttach()
Registers a Broker Attach Server with the EntireX Broker.
|
boolean |
replyError(java.lang.String errorCode,
java.lang.String errorText)
Sends a reply with an error code to the Broker.
|
void |
send(BrokerMessage msg)
Sends an asynchronous non-conversational message.
|
BrokerMessage |
sendReceive(BrokerMessage msg)
Sends a synchronous non-conversational message.
|
BrokerMessage |
sendReceive(BrokerMessage msg,
java.lang.String wait)
Sends a synchronous non-conversational message.
|
void |
setCharacterEncoding(java.lang.String enc)
Sets the character encoding for the payload encoding.
|
void |
setDefaultWaittime(java.lang.String wait)
Sets the value of the default wait time field to the argument.
|
void |
setEnvironment(java.lang.String env)
Sets the value of the environment field to the argument.
|
void |
setMaxReceiveLen(int len)
Sets the current maximum receive length.
|
java.lang.String |
toString()
Overrides the toString() method of Object.
|
boolean |
useCodePage()
If communicating with broker version 7.1.x and below check if a locale
string is sent to the broker or not.
|
void |
useCodePage(boolean b)
Force to send a locale string if communicating with Broker version
7.1.x and below.
|
public static final java.lang.String DEFAULT_WAITTIME
setDefaultWaittime(java.lang.String)
,
Constant Field Valuespublic BrokerService(Broker broker, java.lang.String serverAddr)
broker
- An instance of a Broker object.serverAddr
- The address of the server in the form "serverClass/serverName/serviceName".java.lang.IllegalArgumentException
- Thrown if a parameter is invalid.DEFAULT_WAITTIME
public BrokerService(Broker broker, java.lang.String serverClass, java.lang.String serverName, java.lang.String serviceName)
broker
- An instance of a Broker object.serverClass
- The name of the server class.serverName
- The name of the server.serviceName
- The name of the service.java.lang.IllegalArgumentException
- Thrown if a parameter is invalid.DEFAULT_WAITTIME
public Broker getBroker()
public final java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String getServerName()
public final java.lang.String getServerClass()
public final java.lang.String getServiceName()
public final java.lang.String getEnvironment()
setEnvironment(java.lang.String)
public final void setEnvironment(java.lang.String env)
env
- The value of the Environment field. The maximum length is 32 characters.public final java.lang.String getDefaultWaittime()
DEFAULT_WAITTIME
public final void setDefaultWaittime(java.lang.String wait)
wait
- The new value of the default wait time. Allowed values are
NO
No wait time. Control is returned to the
caller immediately.
nS
The number of seconds the caller will wait
for a reply.
nM
The number of minutes the caller will wait
for a reply.
nH
The number of hours the caller will wait
for a reply.
n
has to be smaller than
100000 and not negative. Setting an illegal value results in
an IllegalArgumentException
on send
,
sendReceive
, or receive
. The value
'YES', specified in the general documentation of the broker
ACI fields is illegal for Java components.DEFAULT_WAITTIME
public final int getMaxReceiveLen()
public final void setMaxReceiveLen(int len)
receive
or sendReceive
method can receive.
If the returned data is longer than the current maximum receive length,
the data is truncated and a BrokerException with
errorclass=20 and errorcode=94 is thrown.
len
- The new receive length in bytes.public final boolean isGeneric()
register
, registerAttach
, and
send
calls are not allowed with generic services.true
if this is a generic Service,
false
otherwise.public final void useCodePage(boolean b)
If set conversion is enabled. The default code page configured for your
Java Virtual Machine will be sent to the Broker as the LOCALE_STRING.
To change the default, see the Java Virtual Machine documentation. On
some implementations, it can be changed with the
file.encoding
property. See the documentation of Java
Virtual Machine on Internationalization for the supported code pages.
If not set the used approach translation or conversion is determined by the configuration of your partner (client or server). See Broker's handling of conversion/translation within the EntireX Internationalization overview for more information. Determines the translation processing of the EntireX Broker.
b
- true
to enable conversion;
false
to use configuration of partner.public final boolean useCodePage()
true
if conversion is enabled;
false
if conversion or translation is determined
by the partner.public final void register() throws BrokerException
BrokerException
- A Broker exception.public final void registerAttach() throws BrokerException
BrokerException
- A Broker exception.receiveAttachInfo()
public final void deregister() throws BrokerException
BrokerException
- A Broker exception.public final void deregisterImmediate() throws BrokerException
BrokerException
- A Broker exception.public final void send(BrokerMessage msg) throws BrokerException
msg
- BrokerMessage to send.BrokerException
- A Broker exception.java.lang.IllegalArgumentException
- Thrown if no message is specified.sendReceive(BrokerMessage, java.lang.String)
public final BrokerMessage sendReceive(BrokerMessage msg) throws BrokerException
msg
- BrokerMessage to send.BrokerException
- A Broker exception.send(com.softwareag.entirex.aci.BrokerMessage)
public final BrokerMessage sendReceive(BrokerMessage msg, java.lang.String wait) throws BrokerException
msg
- BrokerMessage to send.wait
- A timeout period, how long to wait for an immediate reply,
measured in seconds/minutes/hours (depending on the trailing
S/M/H character). The value 'YES', specified in the general
documentation of the broker ACI fields is not allowed for Java
components.BrokerException
- A Broker exception.java.lang.IllegalArgumentException
- Thrown if no message is specified or parameter is invalid.send(com.softwareag.entirex.aci.BrokerMessage)
public final BrokerMessage receive() throws BrokerException
BrokerException
- A Broker exception.public final BrokerMessage receive(java.lang.String wait) throws BrokerException
wait
- A timeout period, how long to wait for a receive, measured in
seconds/minutes/hours (depending on the trailing S/M/H
character). When null or 'NO' is specified, the operation is
non-blocked. If no message is available, a Broker Exception
with errorclass=74 and errorcode=74 is thrown. The value 'YES'
is illegal.BrokerException
- A Broker exception.java.lang.IllegalArgumentException
- Thrown if parameter is invalid.public final BrokerMessage receiveOld() throws BrokerException
BrokerException
- A Broker exception.public final BrokerMessage receiveAny() throws BrokerException
BrokerException
- A Broker exception.public final boolean replyError(java.lang.String errorCode, java.lang.String errorText) throws BrokerException
errorCode
- the error code (must be 8 characters long).errorText
- the error text.true
if the reply is send and the Broker supports
this call.
false
if the current conversation is canceled.
This is the way to signal an error for Brokers which do not
support the function REPLYERROR. In this case
errorCode
and errorText
are
ignored.BrokerException
- if the Broker replies with an error code or this service is
an attach service or a generic service.java.lang.IllegalArgumentException
- if no message is specified.public final void endallConversations() throws BrokerException
BrokerException
- if the Broker replies with an error code.public final void cancelallConversations() throws BrokerException
BrokerException
- A Broker exception.public final BrokerAttachInfo receiveAttachInfo() throws BrokerException
BrokerException
- A Broker exception.registerAttach()
public void setCharacterEncoding(java.lang.String enc) throws BrokerException
The encoding is always sent as the locale string to the Broker if you are communicating with a Broker version 7.2.x or above.
If you are communicating with a Broker version 7.1.x or below the
encoding is sent as the locale string to the Broker after setting the
locale string with this method or after calling
useCodePage(true)
. Setting enc
to
null
disables this and sends no character encoding name to
the Broker. In this case, the default encoding of the JVM is used and the
character encoding is not send to the Broker. Use
setCharacterEncoding("LOCAL")
to send the default encoding
to the Broker.
enc
- the name of the character encoding or LOCAL
or
null
.BrokerException
- if setting the character encoding support fails.public java.lang.String getCharacterEncoding()
null
.