Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Then we send the message with a PersonDocument body to the JPA endpoint. Notice how this endpoint specifies the expected type. So the Type Converter is gonna try convert the PersonDocument to a CustomerEntity. Here Camel will find the CustomerTransformer class which has an @Converter method

...

Please note that when you run the example for the first time, the converter CustomerTransformer will not be able to find any entities inside the database, so that along the logs written into the console you should see:

Code Block
...
thread #0 - file://src/data] CustomerTransformer            INFO  Created a new CustomerEntity Customer[userName: james firstName: null surname: null] as no matching persisted entity found.
...
thread #0 - file://src/data] CustomerTransformer            INFO  Created a new CustomerEntity Customer[userName: hiram firstName: null surname: null] as no matching persisted entity found.
...

However running the example for a second time, as the entites have been already inserted into the database, the log should now say:

Code Block

...
thread #0 - file://src/data] CustomerTransformer            INFO  Found a matching CustomerEntity Customer[userName: james firstName: James surname: Strachan] having the userName james.
...
thread #0 - file://src/data] CustomerTransformer            INFO  Found a matching CustomerEntity Customer[userName: hiram firstName: Hiram surname: Chirino] having the userName hiram.
...

Failing that you can run the Main from inside your IDE if you prefer. Follow the Building instructions to create an Eclipse/IDEA project to import