CamelSpringSimpleMessaging Component

An Apache Camel component for sending messages via Spring's SimpMessageSendingOperations, such as STOMP over websockets.

License

License

Categories

Categories

Messaging Application Layer Libs
GroupId

GroupId

org.jimsey.projects.camel.components
ArtifactId

ArtifactId

camel-spring-simple-messaging
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

CamelSpringSimpleMessaging Component
An Apache Camel component for sending messages via Spring's SimpMessageSendingOperations, such as STOMP over websockets.
Project URL

Project URL

https://github.com/the-james-burton/camel-spring-simple-messaging
Source Code Management

Source Code Management

https://github.com/the-james-burton/camel-spring-simple-messaging

Download camel-spring-simple-messaging

How to add to project

<!-- https://jarcasting.com/artifacts/org.jimsey.projects.camel.components/camel-spring-simple-messaging/ -->
<dependency>
    <groupId>org.jimsey.projects.camel.components</groupId>
    <artifactId>camel-spring-simple-messaging</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.jimsey.projects.camel.components/camel-spring-simple-messaging/
implementation 'org.jimsey.projects.camel.components:camel-spring-simple-messaging:1.0.0'
// https://jarcasting.com/artifacts/org.jimsey.projects.camel.components/camel-spring-simple-messaging/
implementation ("org.jimsey.projects.camel.components:camel-spring-simple-messaging:1.0.0")
'org.jimsey.projects.camel.components:camel-spring-simple-messaging:jar:1.0.0'
<dependency org="org.jimsey.projects.camel.components" name="camel-spring-simple-messaging" rev="1.0.0">
  <artifact name="camel-spring-simple-messaging" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.jimsey.projects.camel.components', module='camel-spring-simple-messaging', version='1.0.0')
)
libraryDependencies += "org.jimsey.projects.camel.components" % "camel-spring-simple-messaging" % "1.0.0"
[org.jimsey.projects.camel.components/camel-spring-simple-messaging "1.0.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.camel : camel-core jar 2.15.3
org.apache.camel : apt jar 2.15.3
org.springframework : spring-messaging jar 4.1.7.RELEASE
org.json : json jar 20140107
org.slf4j : slf4j-api jar 1.7.12

test (7)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.7.12
log4j : log4j jar 1.2.17
junit : junit jar 4.11
org.apache.camel : camel-test jar 2.15.3
org.mockito : mockito-core jar 1.10.19
org.apache.commons : commons-lang3 jar 3.4
org.hamcrest : hamcrest-all jar 1.3

Project Modules

There are no modules declared in this project.

camel-spring-simple-messaging Build Status

Camel spring simple messaging component

This is a component for apache camel that lets you send messages to an implementation of Spring's SimpMessageSendingOperations such as SimpMessagingTemplate.

This is useful when you want to send (for example) STOMP messages over websockets using Spring when using Camel routes.

This is a producer-only component. Consuming messages is not currently supported.

How to get it

It is available in maven central repo here...

<dependency>
    <groupId>org.jimsey.projects.camel.components</groupId>
    <artifactId>camel-spring-simple-messaging</artifactId>
    <version>1.0.0</version>
</dependency>

How to use it

A sample configure method implementation in your Camel RouteBuilder might look like the below. Your implementation of AbstractWebSocketMessageBrokerConfigurer will inject the SimpMessagingTemplate.

@Autowired
private SimpMessagingTemplate template;

@Override
public void configure() throws Exception {

  getContext().addComponent("ssm", new SpringSimpleMessagingComponent(template));

  from("direct:your.message.source")
  .to("ssm://topic/your.topic.name")
  .end();
}

This component will use the camel exchange in body as the SimpMessagingTemplate payload. There are no special requirements for the payload beyond simply being a java Object.

This component will also pass through all headers, including Camel headers except for the control headers documented below.

URI format

<name>://destinaton

Where <name> is the name you gave it when you added the component and destination is where you want to send it to via the Spring SimpMessageSendingOperations.convertAndSend methods. See the options below for how to customise the destination dynamically, via a header.

Options

There are no URI options in this component.

Headers

These messaging control headers are removed before sending to the SimpMessagingTemplate. All other headers will remain on the message.

Header Value
SpringSimpleMessagingConstants.DESTINATION_SUFFIX An optional suffix to add to the destination. Useful to control message routing dynamically.
SpringSimpleMessagingConstants.USER If present, the component will call the convertAndSendToUser message on the SimpMessagingTemplate with the user parameter set to the value of this header. If not present then the convertAndSend method will be used instead, which does not require a user parameter.

How to build

Run mvn install

How to contribute

The Spring API for this is very small, so I don't expect much needs to change for a while. However, anyone is more than welcome to submit a pull request and I will check it, merge it in and release it to maven central.

I am also happy to add additional contributors who submit more than one pull request and/or have bigger plans for this component than I do.

Versions

Version
1.0.0