We utilize a Message Endpoint for all applications to connect to Message Channels for either sending or receiving of messages. The code within this endpoint is customized for both the application and the messaging system’s client API.
The rest of the application will know nothing about message formats, messaging channels, or any of the other communication details for interacting with other applications via messaging. They only are aware that they have a request or information to send to another application, or they are expecting to receive messages from another application.
It is the responsibility of the code within messaging endpoint to retrieve that command or data, transform it into a message, and then send it on to a particular messaging channel. Then, the receiving endpoint will retrieve the message, extract its contents, and pass it to the application in a meaningful way.
Types of endpoint
Apache Camel defines two basic types of endpoint:
Consumer endpoint — This type will appears at the start of a route and will read In messages from an incoming channel (equivalent to a receiver endpoint).
Producer endpoint — This type will appear at the end of a route and writes In messages to an outgoing channel (equivalent to a sender endpoint). It is possible to define a route with multiple producer endpoints.
Endpoint URIs
An endpoint is represented by an endpoint URI, which typically encapsulates the following kinds of data:
Endpoint URI for a consumer endpoint — provides advertising for a specific location (for example, to expose a service to which senders can connect). Alternatively, the URI can specify a message source, such as a message queue. The endpoint URI can include settings to configure the endpoint.
Endpoint URI for a producer endpoint — Contains details of where to send messages and includes the settings to configure the endpoint. In some cases, the URI specifies the location of a remote receiver endpoint; in other cases, the destination can have an abstract form, such as a queue name.
An endpoint URI has the following format:
componentPrefix:componentSpecificURI
NOTE: componentPrefix is a URI prefix that will identify a particular Apache Camel type (jms, file, HTTP, etc), the remaining part of the URI (componentSpecificURI), has a syntax defined by the particular component.
Consumer Endpoint
To define a route that connects the consumer endpoint of file://local/router/messages/foo directly to the producer endpoint of jms:Foo.Bar, we would use the following:
<camelContext id="CamelContextID" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="file://local/router/messages/foo"/> <to uri="jms:Foo.Bar"/> </route> </camelContext>