Package com.bea.wcp.diameter
Class Request
java.lang.Object
com.bea.wcp.diameter.Message
com.bea.wcp.diameter.Request
Diameter request message. Request extends Message with the ability
to directly get and set the destination host, destination realm,
and ApplicationId for the request.
- Author:
- Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
-
Field Summary
Fields inherited from class com.bea.wcp.diameter.Message
FLAG_ERROR, FLAG_POTENTIALLY_RETRANSMITTED, FLAG_PROXIABLE, FLAG_REQUEST, FLAGS_MASK, HEADER_SIZE, VERSION -
Constructor Summary
ConstructorsConstructorDescriptionRequest(Command cmd, Application app) Creates a new Request for the specified application and command.Creates a new Request for the specified session and command.Creates a new Request for a given command, application, and optional session identifier.Request(ByteBuffer bb, com.bea.wcp.diameter.transport.Connection c) Creates a new Request decoded from the specified message bytes. -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidcancel()voidcommit()Commits the request and sends it to the destination peer or realm.Creates an Answer message for this request.createAnswer(ResultCode rc, String error) Creates a new Answer message for this request.Returns the ApplicationId for this request, or null if none.Returns the destination host for this request, or null if none.Peer[]Returns the destination peers for this request.Returns the destination realm for this request.getNode()booleanbooleanreturns if load balance enabled for this route or not.Returns the session associated with this request.booleanReturns true if this request has already been answered.booleanReturns true if the request has been committed.booleanvoidPerforms initial validation of a message to include validation of AVPs required to determine if the request/answer should be forwarded.protected voidpreValidateAvp(Avp avp) Fully decodes and validates the specified AVP.voidAdds proxy info AVP to the list representing the current node.voidsend()Sends this Diameter message.voidsend(long timeout) Sends the request.sendAndWait(long timeout) voidSends an error answer for this request and the specified exception.voidvoidSets the ApplicationId for the request.voidsetDestinationHost(String host) Sets the destination host for this request.voidsetDestinationRealm(String realm) Sets the destination realm for the request.static voidvoidsetRetrySupported(boolean canRetry) voidsetSession(Session session) voidUnsets the destination host for this request and removes the Destination-Host AVP.Methods inherited from class com.bea.wcp.diameter.Message
addAvp, addAvp, addAvp, appendXml, decode, decodeAvps, encode, encode, extractAndSetSessionIdAvp, getAppId, getAppId, getAvp, getAvp, getAvpList, getCode, getCode, getCommand, getConnection, getEffectiveSessionId, getEndToEndId, getHopByHopId, getLength, getOriginHost, getOriginRealm, getSessionId, getVersion, isAnswer, isError, isPotentiallyRetransmitted, isProxiable, isRequest, popProxyInfo, toLoggableString, toString, validate, validateAvp
-
Constructor Details
-
Request
Creates a new Request for a given command, application, and optional session identifier.- Parameters:
node- the Diameter Node originating the requestcmd- the request commandappId- the message header application identifiersessionId- the session identifier AVP value, or null if none
-
Request
Creates a new Request for the specified application and command.- Parameters:
cmd- the Command for the requestapp- the Application for the request
-
Request
Creates a new Request for the specified session and command.- Parameters:
session- the Diameter session for this requestcmd- the Request command name
-
Request
Creates a new Request decoded from the specified message bytes.- Parameters:
bb- the message bytesc- the connection used to receive the message
-
-
Method Details
-
getNode
-
preValidate
Description copied from class:MessagePerforms initial validation of a message to include validation of AVPs required to determine if the request/answer should be forwarded. If we determine the message should be handled locally, then the remaining AVPs will be validated by 'validate()'.- Overrides:
preValidatein classMessage- Throws:
MessageException- if validation failed
-
preValidateAvp
Description copied from class:MessageFully decodes and validates the specified AVP. Message implementations can override this to provide additional validation or to cache AVP results.- Overrides:
preValidateAvpin classMessage- Parameters:
avp- the AVP to be validated- Throws:
AvpException- if the AVP was invalid
-
createAnswer
Creates an Answer message for this request. The relevant header fields and AVPs will be copied from the original request (see RFC 3588). -
createAnswer
Creates a new Answer message for this request. An Error-Message AVP will be included if the specified error message is not null.- Parameters:
rc- the ResultCode for the answererror- the error message or null if none- Returns:
- the Answer message for the request
-
sendError
Sends an error answer for this request and the specified exception.- Parameters:
ex- the exception that caused the error- Throws:
IOException- if the answer could not be sent
-
getDestinationHost
Returns the destination host for this request, or null if none. This corresponds to the value of the Destination-Host AVP. -
getDestinationRealm
Returns the destination realm for this request. This corresponds to the value of the Destination-Realm AVP. -
getApplicationId
Returns the ApplicationId for this request, or null if none. This corresponds to one of the Auth-Application-Id, Acct-Application-Id, or Vendor-Specific-Application-Id AVPs. A different application id can be specified in the message header itself. -
setDestinationHost
Sets the destination host for this request. This will result in the Destination-Host AVP being added to the request.- Parameters:
host- the destination host- Throws:
IllegalStateException- if the destination host has already been set
-
unsetDestinationHost
public void unsetDestinationHost()Unsets the destination host for this request and removes the Destination-Host AVP. -
setDestinationRealm
Sets the destination realm for the request. This will result in the Destination-Realm AVP being added to the request. The destination realm can only be set once, and must be set if the request is proxiable.- Parameters:
realm- the destination realm- Throws:
IllegalStateException- if the destination realm has already been set
-
setApplicationId
Sets the ApplicationId for the request. This will result in one of the Auth-Application-Id, Acct-Application-Id, or Vendor-Specific-Application-Id AVPs being added to the request. The ApplicationId can be different from the application id specified in the message header. The ApplicationId can only be set once, and must be set if the request is proxiable.- Parameters:
id- the ApplicationId for the request- Throws:
IllegalStateException- if the application id has already been set
-
setSession
-
getSession
Returns the session associated with this request.- Specified by:
getSessionin classMessage- Returns:
- the Session for this Request, or null if none
-
commit
Commits the request and sends it to the destination peer or realm.- Specified by:
commitin classMessage- Throws:
IOException- if an I/O error occurred while sending
-
isCommitted
public boolean isCommitted()Returns true if the request has been committed.- Specified by:
isCommittedin classMessage- Returns:
- true if committed, false otherwise
-
send
Sends the request. If the destination host has been set, then the request will be sent directly to the peer associated with the host. Otherwise, the message will be routed based on destination realm and application identifier.- Throws:
IOException- if an I/O error has occurred
-
send
Description copied from class:MessageSends this Diameter message.- Specified by:
sendin classMessage- Throws:
IOException- if an I/O error occurred while sending
-
sendAndWait
- Parameters:
timeout-- Returns:
- Throws:
IOException
-
sendAndWait
- Throws:
IOException
-
attemptFailover
public boolean attemptFailover() -
getRetrySupported
public boolean getRetrySupported() -
setRetrySupported
public void setRetrySupported(boolean canRetry) -
isThreadWaiting
public boolean isThreadWaiting() -
setAnswer
-
getAnswer
-
isAnswered
public boolean isAnswered()Returns true if this request has already been answered. -
cancel
public void cancel() -
getDestinationPeers
Returns the destination peers for this request. If Destination-Host AVP is present and is a configured peer, then returns a list with just that peer. Otherwise, returns list of available peers according to Destination-Route AVP (realm-based routing).- Returns:
- list of destination peers
- Throws:
IOException- if no destination peers are available
-
getRouteDLBEnabled
returns if load balance enabled for this route or not.- Throws:
IOException
-
pushProxyInfo
public void pushProxyInfo()Adds proxy info AVP to the list representing the current node. Additionally, allocates a new hop-by-hop identifier for this request. -
setIsPotentiallyRetransmitted
-