Package org.apache.camel.component.xmpp
Class XmppEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.component.xmpp.XmppEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.spi.HeaderFilterStrategyAware
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="1.0", scheme="xmpp", title="XMPP", syntax="xmpp:host:port/participant", alternativeSyntax="xmpp:user:password@host:port/participant", category={CHAT,MESSAGING}) public class XmppEndpoint extends org.apache.camel.support.DefaultEndpoint implements org.apache.camel.spi.HeaderFilterStrategyAware
Send and receive messages to/from an XMPP chat server.
-
-
Constructor Summary
Constructors Constructor Description XmppEndpoint()
XmppEndpoint(String uri, XmppComponent component)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.jivesoftware.smack.tcp.XMPPTCPConnection
createConnection()
org.apache.camel.Consumer
createConsumer(org.apache.camel.Processor processor)
org.apache.camel.Producer
createDirectProducer()
protected String
createEndpointUri()
org.apache.camel.Exchange
createExchange(org.jivesoftware.smack.packet.Stanza packet)
org.apache.camel.Producer
createGroupChatProducer()
org.apache.camel.Producer
createPrivateChatProducer(String participant)
org.apache.camel.Producer
createProducer()
org.apache.camel.Producer
createPubSubProducer()
protected void
doStop()
XmppBinding
getBinding()
String
getChatId()
org.jivesoftware.smack.ConnectionConfiguration
getConnectionConfig()
String
getConnectionDescription()
static String
getConnectionMessage(org.jivesoftware.smack.XMPPConnection connection)
int
getConnectionPollDelay()
org.apache.camel.spi.HeaderFilterStrategy
getHeaderFilterStrategy()
String
getHost()
String
getNickname()
String
getParticipant()
String
getPassword()
int
getPort()
String
getResource()
String
getRoom()
protected String
getRoomPassword()
String
getServiceName()
String
getUser()
boolean
isCreateAccount()
boolean
isDoc()
boolean
isLogin()
boolean
isPubsub()
boolean
isTestConnectionOnStartup()
String
resolveParticipant(org.jivesoftware.smack.XMPPConnection connection)
If there is no "@" symbol in the participant, find the service domain JID and return the fully qualified JID for the participant as user@server.domainString
resolveRoom(org.jivesoftware.smack.XMPPConnection connection)
void
setBinding(XmppBinding binding)
Sets the binding used to convert from a Camel message to and from an XMPP messagevoid
setConnectionConfig(org.jivesoftware.smack.ConnectionConfiguration connectionConfig)
To use an existing connection configuration.void
setConnectionPollDelay(int connectionPollDelay)
The amount of time in seconds between polls (in seconds) to verify the health of the XMPP connection, or between attempts to establish an initial consumer connection.void
setCreateAccount(boolean createAccount)
If true, an attempt to create an account will be made.void
setDoc(boolean doc)
Set a doc header on the IN message containing a Document form of the incoming packet; default is true if presence or pubsub are true, otherwise falsevoid
setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
To use a custom HeaderFilterStrategy to filter header to and from Camel message.void
setHost(String host)
Hostname for the chat servervoid
setLogin(boolean login)
Whether to login the user.void
setNickname(String nickname)
Use nickname when joining room.void
setParticipant(String participant)
JID (Jabber ID) of person to receive messages.void
setPassword(String password)
Password for loginvoid
setPort(int port)
Port number for the chat servervoid
setPubsub(boolean pubsub)
Accept pubsub packets on input, default is falsevoid
setResource(String resource)
XMPP resource.void
setRoom(String room)
If this option is specified, the component will connect to MUC (Multi User Chat).void
setRoomPassword(String roomPassword)
Password for roomvoid
setServiceName(String serviceName)
The name of the service you are connecting to.void
setTestConnectionOnStartup(boolean testConnectionOnStartup)
Specifies whether to test the connection on startup.void
setUser(String user)
User name (without server name).-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configurePollingConsumer, configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, doInit, doStart, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isSingleton, isSynchronous, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
XmppEndpoint
public XmppEndpoint()
-
XmppEndpoint
public XmppEndpoint(String uri, XmppComponent component)
-
-
Method Detail
-
createProducer
public org.apache.camel.Producer createProducer() throws Exception
- Specified by:
createProducer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
createGroupChatProducer
public org.apache.camel.Producer createGroupChatProducer() throws Exception
- Throws:
Exception
-
createPrivateChatProducer
public org.apache.camel.Producer createPrivateChatProducer(String participant) throws Exception
- Throws:
Exception
-
createDirectProducer
public org.apache.camel.Producer createDirectProducer() throws Exception
- Throws:
Exception
-
createPubSubProducer
public org.apache.camel.Producer createPubSubProducer() throws Exception
- Throws:
Exception
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
- Specified by:
createConsumer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
createExchange
public org.apache.camel.Exchange createExchange(org.jivesoftware.smack.packet.Stanza packet)
-
createEndpointUri
protected String createEndpointUri()
- Overrides:
createEndpointUri
in classorg.apache.camel.support.DefaultEndpoint
-
createConnection
public org.jivesoftware.smack.tcp.XMPPTCPConnection createConnection() throws InterruptedException, IOException, org.jivesoftware.smack.SmackException, org.jivesoftware.smack.XMPPException
- Throws:
InterruptedException
IOException
org.jivesoftware.smack.SmackException
org.jivesoftware.smack.XMPPException
-
resolveParticipant
public String resolveParticipant(org.jivesoftware.smack.XMPPConnection connection)
If there is no "@" symbol in the participant, find the service domain JID and return the fully qualified JID for the participant as user@server.domain
-
resolveRoom
public String resolveRoom(org.jivesoftware.smack.XMPPConnection connection) throws InterruptedException, org.jivesoftware.smack.SmackException, org.jivesoftware.smack.XMPPException
- Throws:
InterruptedException
org.jivesoftware.smack.SmackException
org.jivesoftware.smack.XMPPException
-
getConnectionDescription
public String getConnectionDescription()
-
getConnectionMessage
public static String getConnectionMessage(org.jivesoftware.smack.XMPPConnection connection)
-
getChatId
public String getChatId()
-
getBinding
public XmppBinding getBinding()
-
setBinding
public void setBinding(XmppBinding binding)
Sets the binding used to convert from a Camel message to and from an XMPP message
-
getHost
public String getHost()
-
setHost
public void setHost(String host)
Hostname for the chat server
-
getPort
public int getPort()
-
setPort
public void setPort(int port)
Port number for the chat server
-
getUser
public String getUser()
-
setUser
public void setUser(String user)
User name (without server name). If not specified, anonymous login will be attempted.
-
getPassword
public String getPassword()
-
setPassword
public void setPassword(String password)
Password for login
-
getResource
public String getResource()
-
setResource
public void setResource(String resource)
XMPP resource. The default is Camel.
-
isLogin
public boolean isLogin()
-
setLogin
public void setLogin(boolean login)
Whether to login the user.
-
isCreateAccount
public boolean isCreateAccount()
-
setCreateAccount
public void setCreateAccount(boolean createAccount)
If true, an attempt to create an account will be made. Default is false.
-
getRoom
public String getRoom()
-
setRoom
public void setRoom(String room)
If this option is specified, the component will connect to MUC (Multi User Chat). Usually, the domain name for MUC is different from the login domain. For example, if you are superman@jabber.org and want to join the krypton room, then the room URL is krypton@conference.jabber.org. Note the conference part. It is not a requirement to provide the full room JID. If the room parameter does not contain the @ symbol, the domain part will be discovered and added by Camel
-
setRoomPassword
public void setRoomPassword(String roomPassword)
Password for room
-
getRoomPassword
protected String getRoomPassword()
-
getParticipant
public String getParticipant()
-
setParticipant
public void setParticipant(String participant)
JID (Jabber ID) of person to receive messages. room parameter has precedence over participant.
-
getNickname
public String getNickname()
-
setNickname
public void setNickname(String nickname)
Use nickname when joining room. If room is specified and nickname is not, user will be used for the nickname.
-
setServiceName
public void setServiceName(String serviceName)
The name of the service you are connecting to. For Google Talk, this would be gmail.com.
-
getServiceName
public String getServiceName()
-
getHeaderFilterStrategy
public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
- Specified by:
getHeaderFilterStrategy
in interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
To use a custom HeaderFilterStrategy to filter header to and from Camel message.- Specified by:
setHeaderFilterStrategy
in interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
getConnectionConfig
public org.jivesoftware.smack.ConnectionConfiguration getConnectionConfig()
-
setConnectionConfig
public void setConnectionConfig(org.jivesoftware.smack.ConnectionConfiguration connectionConfig)
To use an existing connection configuration. CurrentlyXMPPTCPConnectionConfiguration
is only supported (XMPP over TCP).
-
isTestConnectionOnStartup
public boolean isTestConnectionOnStartup()
-
setTestConnectionOnStartup
public void setTestConnectionOnStartup(boolean testConnectionOnStartup)
Specifies whether to test the connection on startup. This is used to ensure that the XMPP client has a valid connection to the XMPP server when the route starts. Camel throws an exception on startup if a connection cannot be established. When this option is set to false, Camel will attempt to establish a "lazy" connection when needed by a producer, and will poll for a consumer connection until the connection is established. Default is true.
-
getConnectionPollDelay
public int getConnectionPollDelay()
-
setConnectionPollDelay
public void setConnectionPollDelay(int connectionPollDelay)
The amount of time in seconds between polls (in seconds) to verify the health of the XMPP connection, or between attempts to establish an initial consumer connection. Camel will try to re-establish a connection if it has become inactive. Default is 10 seconds.
-
setPubsub
public void setPubsub(boolean pubsub)
Accept pubsub packets on input, default is false
-
isPubsub
public boolean isPubsub()
-
setDoc
public void setDoc(boolean doc)
Set a doc header on the IN message containing a Document form of the incoming packet; default is true if presence or pubsub are true, otherwise false
-
isDoc
public boolean isDoc()
-
-