History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CAMEL-659
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Willem Jiang
Reporter: Michael Kahn
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Apache Camel

XMPP endpoint should should auto-reconnect if it loses connection to the xmpp server

Created: 03/Jul/08 03:40 AM   Updated: 07/Aug/08 11:23 PM
Component/s: camel-xmpp
Affects Version/s: 1.3.0, 1.4.0
Fix Version/s: 1.5.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works camel-xmpp-smack_3_0_4.patch 2008-07-10 04:49 AM freetwix 12 kb


 Description  « Hide
In 1.3.0, XmppEndpoint.java and related classes use the smack 2.2.1 API, and have a getConnection() method that sets up and caches the xmpp connection and chat once when the endpoint is initialized. If the network connection to the xmpp server is subsequently lost, attempts to route throw an exception. This makes use of this component on remote and roaming/wireless devices difficult.

Smack API 3.0.4+ (the only version available for "official" download right now) should auto-reconnect the XMPPConnection once it is created, reusing the same credentials from the current login() session, however the API is not a drop-in replacement, there are a few differences. It also isn't in the maven repository yet - that maxes out at 2.2.1.



 All   Comments   Work Log   Change History   Subversion Commits   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Claus Ibsen - 04/Jul/08 01:32 PM
Michael thanks for the report and the maven investigations.

This is quite a problem that frameworks doesn't upgrades in the maven repos.


Michael Kahn - 05/Jul/08 04:49 AM
I probably should not be asking this here - however, is there a general architectural approach in camel for reconnecting or attempting to reinitialize a route that is failing due to an IO-type error or exception? I mean not just with the XMPP component but with components in general. It seems to me if certain errors occur "downstream", such as the above failure to connect to the XMPP server, the entire route (i.e.: consuming the inbound endpoint) should/could be suspended until the route can be properly reestablished. Is this a feature that is there already that I am missing?

Claus Ibsen - 05/Jul/08 06:15 AM
Yes please ask at the user forum. Much broader audience to shed some light on this matter.

Claus Ibsen - 10/Jul/08 12:40 AM
Michael if you are able to find it Smack API on any maven repo that would be great. We need a maven repo where we can get the .jars from.

freetwix - 10/Jul/08 04:49 AM
Hey, this is a working port of camel-xmpp to smack 3.0.4. I didn't get the maven repo stuff to work (as mentioned on the smack forum - see comments in the pom.xml) - need to download it manual and tweak the local maven repo.
i added a todo for the nickname stuff. think it would be nice to add the nickname to the room uri (like room1@foo.com/dude) and parse it when consuming the room.
the code works with openfire 3.5.1/2. i will submit new changes as patches here, too, and hereby grant all rights of the patch code to ASF.

hope the patch will help and are appreciating comments and more suggestions,
greets
freetwix

ps: tried to be javaesk though on the ruby path these days ...


Claus Ibsen - 11/Jul/08 10:59 PM
Hi Freetwix

The "_amq" what does it really do? Do you have a link to some documentation that explains this "feature"?


Michael Kahn - 12/Jul/08 04:26 AM
Wow, that was quick, thanks Claus. I looked for a maven repo with the new smack API and could not find one. How would one get it added to the main repo?

Claus Ibsen - 12/Jul/08 04:33 AM
I do think our friends at SeriviceMix have a maven repo where we could have the smack hosted.

But no promises. In fact we have other components that hang on older .jars because sadly the central maven repos out there tend to not get updated. So its a pain in the ass to find a decent maven repo that host the jars.


freetwix - 12/Jul/08 07:14 AM
hey claus,

the '_amq' is just an extension to the username providing a unique nickname of the amq user in the muc. a nickname in a muc needs to be unique, else an exception will be raised.
you found the point what i meant by 'think it would be nice to add the nickname to the room uri (like room1@foo.com/dude) and parse it when consuming the room.'.
it would be ok to just use the username, too - it was just in my current project that the same username already entered the muc and i really needed another nick for the camel user.
i just recommend the smack sources for documentation, and sorry, the '_amq' feature wasn't really documented at all.

greets,
freetwix


Vadim Chekan - 13/Jul/08 12:20 AM
Nice job Michael,
I have a question about the fragment:
  • if (shouldOutputHeader(exchange, name, value)) {
    + // BUG?
    + if (value != null && shouldOutputHeader(exchange, name, value)) {

Does it cause errors having a header without value? I can imagine situation when it matters just the fact that header is in the message and there is no need to put any value into it. Or indication of empty set.


freetwix - 14/Jul/08 01:47 AM
Hey Vadim,

the problem is the serialization of null which will cause an error.


Vadim Chekan - 23/Jul/08 11:20 PM
Hmm, may be sending empty string is possible? It may cost a lot of time for user to understand why header vanishes.

Claus Ibsen - 31/Jul/08 10:55 PM
Okay the smack API is somewhere on a maven repo

<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack</artifactId>
<version>3.0.4</version>
</project>


Claus Ibsen - 01/Aug/08 12:45 AM
I think we need the good servicemix guys to put smack on their repo

Claus Ibsen - 06/Aug/08 12:58 AM
There are two artifacts needed:
<artifactId>smack</artifactId>
and
<artifactId>smackx</artifactId>

Gertv will look into adding the jars to the servicemix maven repo later.


Gert Vanthienen - 06/Aug/08 02:55 AM
Artifacts org.igniterealtime.smack:smack:3.0.4 and org.igniterealtime.smack:smackx:3.0.4 have been added to the servicemix repo.

Claus Ibsen - 06/Aug/08 03:09 AM
Thanks Gert. I will modify the pom.xml so we grab these new babies.

And I guess Vadim, Michael or other can help upgrade the java code in camel-xmpp if anything is needed.


Claus Ibsen - 06/Aug/08 03:10 AM
BTW: If anyone beats me to it feel free to modify the pom.xml so we are using 3.0.4 that can be resolved in the servicemix repo. Check out the saxon component where the servicemix repo is added as a maven repo.

Claus Ibsen - 06/Aug/08 11:19 AM
Anyone up for the task of creating a patch for the upgrade to smack 3.0.4. Michael, sorry we have changed the camel-xmpp quite a bit lately so your original patch must be redone.

We have a maven repo with the 3.0.4 jars now.

1) Add this to pom.xml
<repositories>
<!-- ServiceMix repo -->
<repository>
<id>servicemix</id>
<name>Apache ServiceMix Repository</name>
<url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
</repository>
</repositories>

2) Upgrade to 3.0.4 in pom.xml
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smackx</artifactId>
<version>3.0.4</version>
</dependency>

Then you are set. You will get some compilation errors since the API in 3.0 is different than 2.x.


Willem Jiang - 07/Aug/08 11:23 PM
I just manually apply the patch, please try it out
http://svn.apache.org/viewvc?rev=683640&view=rev