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.ComponentAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, 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}, headersClass=XmppConstants.class) 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.
  • Field Summary

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jivesoftware.smack.tcp.XMPPTCPConnection
     
    org.apache.camel.Consumer
    createConsumer(org.apache.camel.Processor processor)
     
    org.apache.camel.Producer
     
    protected String
     
    org.apache.camel.Producer
     
    org.apache.camel.Producer
     
    org.apache.camel.Producer
     
    org.apache.camel.Producer
     
    protected void
     
     
     
    org.jivesoftware.smack.ConnectionConfiguration
     
     
    static String
    getConnectionMessage(org.jivesoftware.smack.XMPPConnection connection)
     
    int
     
    org.apache.camel.spi.HeaderFilterStrategy
     
     
     
     
     
    int
     
     
     
    protected String
     
     
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    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 [email protected]
    resolveRoom(org.jivesoftware.smack.XMPPConnection connection)
     
    void
    Sets the binding used to convert from a Camel message to and from an XMPP message
    void
    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 false
    void
    setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy headerFilterStrategy)
    To use a custom HeaderFilterStrategy to filter header to and from Camel message.
    void
    Hostname for the chat server
    void
    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 login
    void
    setPort(int port)
    Port number for the chat server
    void
    setPubsub(boolean pubsub)
    Accept pubsub packets on input, default is false
    void
    setResource(String resource)
    XMPP resource.
    void
    If this option is specified, the component will connect to MUC (Multi User Chat).
    void
    setRoomPassword(String roomPassword)
    Password for room
    void
    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
    User name (without server name).

    Methods inherited from class org.apache.camel.support.DefaultEndpoint

    configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStart, 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

    Methods inherited from interface org.apache.camel.ComponentAware

    getComponent

    Methods inherited from interface org.apache.camel.Endpoint

    getEndpointBaseUri, isSingletonProducer

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Constructor Details

    • XmppEndpoint

      public XmppEndpoint()
    • XmppEndpoint

      public XmppEndpoint(String uri, XmppComponent component)
  • Method Details

    • createProducer

      public org.apache.camel.Producer createProducer() throws Exception
      Specified by:
      createProducer in interface org.apache.camel.Endpoint
      Throws:
      Exception
    • createGroupChatProducer

      public org.apache.camel.Producer createGroupChatProducer()
    • createPrivateChatProducer

      public org.apache.camel.Producer createPrivateChatProducer(String participant)
    • createDirectProducer

      public org.apache.camel.Producer createDirectProducer()
    • createPubSubProducer

      public org.apache.camel.Producer createPubSubProducer()
    • createConsumer

      public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
      Specified by:
      createConsumer in interface org.apache.camel.Endpoint
      Throws:
      Exception
    • createEndpointUri

      protected String createEndpointUri()
      Overrides:
      createEndpointUri in class org.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 [email protected]
    • 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 [email protected] and want to join the krypton room, then the room URL is [email protected]. 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 interface org.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 interface org.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. Currently XMPPTCPConnectionConfiguration 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()
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception