...
Div |
---|
class | confluenceTableSmall |
---|
|
Option | Default | Description |
---|
clientId | camel-<timestamp> | MQTT client identifier. | brokerUrl
| tcp://localhost:1883
| The URL of the MQTT broker. | persistence | memory | Client persistence to be used - memory or file . | qos | 2 | Client quality of service level (0 -2 ). |
|
Example
Examples
Read messages from the MQTT broker installed on the same host as the Camel router:Assumed we have a java bean with the following annotations
Code Block |
---|
|
public class Car {
@NotNull
private String manufacturer;
@NotNull
@Size(min = 5, max = 14, groups = OptionalChecks.class)
private String licensePlate;
// getter and setter
}
|
and an interface definition for our custom validation group
Code Block |
---|
|
public interface OptionalChecks {
}
|
...
|
Code Block |
---|
from("directpaho:startsome/queue")
.to("bean-validator://x")
..
to("mock:endtest")
|
If you want to check the constraints from the group OptionalChecks
, you have to define the route like this
Read messages from the remote MQTT broker:
Code Block |
---|
|
code |
from("direct:start")
.to("bean-validator://x?group=OptionalChecks")
.paho:some/queue?brokerUrl=tcp://iot.eclipse.org:1883").
to("mock:endtest")
; |
Send message to the MQTT broker:If you want to check the constraints from both groups, you have to define a new interface first
Code Block |
---|
| @GroupSequence({Default.class, OptionalChecks.class})
public interface AllChecks {
}
|
and then your route definition should looks like this
Code Block |
---|
from("direct:start")
.to("bean-validator://x?group=AllChecks")
.to("mock:end")
|
And if you have to provide your own message interpolator, traversable resolver and constraint validator factory, you have to write a route like this
Code Block |
---|
<bean id="myMessageInterpolator" class="my.ConstraintValidatorFactory" />
<bean id="myTraversableResolver" class="my.TraversableResolver" />
<bean id="myConstraintValidatorFactory" class="my.ConstraintValidatorFactory" />
from("direct:start")
.to("bean-validator://x?group=AllChecks&messageInterpolator=#myMessageInterpolator
&traversableResolver=#myTraversableResolver&constraintValidatorFactory=#myConstraintValidatorFactory")
.to("mock:end")
|
It's also possible to describe your constraints as XML and not as Java annotations. In this case, you have to provide the file META-INF/validation.xml
which could looks like this
...
test").
to("paho:some/target/queue"); |
Include Page |
---|
| Endpoint See Also |
---|
| Endpoint See Also |
---|
|