Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed broken link to Yammer authentication doc

...

Yammer uses OAuth 2 for all client application authentication. In order to use camel-yammer with your account, you'll need to create a new application within Yammer and grant the application access to your account. Finally, generate your access token. More details are at https://developer.yammer.com/v1.0/docs/authentication/

Maven users will need to add the following dependency to their pom.xml for this component:

Code Block
xml
xml

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-yammer</artifactId>
    <version>${camel-version}</version>
</dependency>

URI format

Code Block

yammer:[function]?[options]

...

All messages by default are converted to a POJO model provided in the org.apache.camel.component.yammer.model package. The original message coming from yammer is in JSON. For all message consuming & producing endpoints, a Messages object is returned. Take for example a route like:

Code Block

from("yammer:messages?consumerKey=aConsumerKey&consumerSecret=aConsumerSecretKey&accessToken=aAccessToken").to("mock:result");

and lets say the yammer server returns:

Code Block

{
	"messages":[
		{
			"replied_to_id":null,
			"network_id":7654,
			"url":"https://www.yammer.com/api/v1/messages/305298242",
			"thread_id":305298242,
			"id":305298242,
			"message_type":"update",
			"chat_client_sequence":null,
			"body":{
				"parsed":"Testing yammer API...",
				"plain":"Testing yammer API...",
				"rich":"Testing yammer API..."
			},
			"client_url":"https://www.yammer.com/",
			"content_excerpt":"Testing yammer API...",
			"created_at":"2013/06/25 18:14:45 +0000",
			"client_type":"Web",
			"privacy":"public",
			"sender_type":"user",
			"liked_by":{
				"count":1,
				"names":[
					{
						"permalink":"janstey",
						"full_name":"Jonathan Anstey",
						"user_id":1499642294
					}
					
				]
				
			},
			"sender_id":1499642294,
			"language":null,
			"system_message":false,
			"attachments":[
				
			],
			"direct_message":false,
			"web_url":"https://www.yammer.com/redhat.com/messages/305298242"
		},
		{
			"replied_to_id":null,
			"network_id":7654,
			"url":"https://www.yammer.com/api/v1/messages/294326302",
			"thread_id":294326302,
			"id":294326302,
			"message_type":"system",
			"chat_client_sequence":null,
			"body":{
				"parsed":"(Principal Software Engineer) has [[tag:14658]] the redhat.com network. Take a moment to welcome Jonathan.",
				"plain":"(Principal Software Engineer) has #joined the redhat.com network. Take a moment to welcome Jonathan.",
				"rich":"(Principal Software Engineer) has #joined the redhat.com network. Take a moment to welcome Jonathan."
			},
			"client_url":"https://www.yammer.com/",
			"content_excerpt":"(Principal Software Engineer) has #joined the redhat.com network. Take a moment to welcome Jonathan.",
			"created_at":"2013/05/10 19:08:29 +0000",
			"client_type":"Web",
			"sender_type":"user",
			"privacy":"public",
			"liked_by":{
				"count":0,
				"names":[
					
				]
				
			}
		}	
		]
		
	}

Camel will marshal that into a Messages object containing 2 Message objects. As shown below there is a rich object model that makes it easy to get any information you need:

Code Block

        Exchange exchange = mock.getExchanges().get(0);
        Messages messages = exchange.getIn().getBody(Messages.class);

        assertEquals(2, messages.getMessages().size());
        assertEquals("Testing yammer API...", messages.getMessages().get(0).getBody().getPlain());
        assertEquals("(Principal Software Engineer) has #joined the redhat.com network. Take a moment to welcome Jonathan.", messages.getMessages().get(1).getBody().getPlain());

...

To create a new message in the account of the current user, you can use the following URI:

Code Block

yammer:messages?[options]

...

Take this route for instance:

Code Block

from("direct:start").to("yammer:messages?consumerKey=aConsumerKey&consumerSecret=aConsumerSecretKey&accessToken=aAccessToken").to("mock:result");

By sending to the direct:start endpoint a "Hi from Camel!" message body:

Code Block

        template.sendBody("direct:start", "Hi from Camel!");

...

The camel-yammer component can retrieve user relationships:

Code Block

yammer:relationships?[options]

...

Lets say you have a route that at some point needs to go out and fetch user data for the current user. Rather than polling for this user over and over again, use the pollEnrich DSL method:

Code Block

from("direct:start").pollEnrich("yammer:current?consumerKey=aConsumerKey&consumerSecret=aConsumerSecretKey&accessToken=aAccessToken").to("mock:result");

This will go out and fetch the current user's User object and set it as the Camel message body.

Include Page
Endpoint See Also
Endpoint See Also