Yammer
Skip to end of metadata
Go to start of metadata

Yammer

Available as of Camel 2.12

The Yammer component allows you to interact with the Yammer enterprise social network. Consuming messages, users, and user relationships is supported as well as creating new messages.

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/authentication/

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

URI format

YammerComponent

The yammer component can be configured with the Yammer account settings which are mandatory to configure before using. You can also configure these options directly in the endpoint.

Option

Description

consumerKey

The consumer key

consumerSecret

The consumer secret

accessToken

The access token

Consuming messages

The camel-yammer component provides several endpoints for consuming messages:

URI

Description

All public messages in the user's (whose access token is being used to make the API call) Yammer network. Corresponds to "All" conversations in the Yammer web interface.

The user's feed, based on the selection they have made between "Following" and "Top" conversations.

The algorithmic feed for the user that corresponds to "Top" conversations, which is what the vast majority of users will see in the Yammer web interface.

The "Following" feed which is conversations involving people, groups and topics that the user is following.

All messages sent by the user.

Private messages received by the user.

Camel 2.12.1: All messages received by the user

URI Options for consuming messages

Name

Default Value

Description

useJson

false

Set to true if you want to use raw JSON rather than converting to POJOs.

delay

5000

in milliseconds

consumerKey

null

Consumer Key. Can also be configured on the YammerComponent level instead.

consumerSecret

null

Consumer Secret. Can also be configured on the YammerComponent level instead.

accessToken

null

Access Token. Can also be configured on the YammerComponent level instead.

limit

-1

Return only the specified number of messages. Works for threaded=true and threaded=extended.

threaded

null

threaded=true will only return the first message in each thread. This parameter is intended for apps which display message threads collapsed. threaded=extended will return the thread starter messages in order of most recently active as well as the two most recent messages, as they are viewed in the default view on the Yammer web interface.

olderThan

-1

Returns messages older than the message ID specified as a numeric string. This is useful for paginating messages. For example, if you're currently viewing 20 messages and the oldest is number 2912, you could append "?olderThan=2912″ to your request to get the 20 messages prior to those you're seeing.

newerThan

-1

Returns messages newer than the message ID specified as a numeric string. This should be used when polling for new messages. If you're looking at messages, and the most recent message returned is 3516, you can make a request with the parameter "?newerThan=3516″ to ensure that you do not get duplicate copies of messages already on your page.

Message format

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:

and lets say the yammer server returns:

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:

That said, marshaling this data into POJOs is not free so if you need you can switch back to using pure JSON by adding the useJson=false option to your URI.

Creating messages

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

The current Camel message body is what will be used to set the text of the Yammer message. The response body will include the new message formatted the same way as when you consume messages (i.e. as a Messages object by default).

Take this route for instance:

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

a new message will be created in the current user's account on the server and also this new message will be returned to Camel and converted into a Messages object. Like when consuming messages you can interrogate the Messages object:

Retrieving user relationships

The camel-yammer component can retrieve user relationships:

URI Options for retrieving relationships

Name

Default Value

Description

useJson

false

Set to true if you want to use raw JSON rather than converting to POJOs.

delay

5000

in milliseconds

consumerKey

null

Consumer Key. Can also be configured on the YammerComponent level instead.

consumerSecret

null

Consumer Secret. Can also be configured on the YammerComponent level instead.

accessToken

null

Access Token. Can also be configured on the YammerComponent level instead.

userId

current user

To view the relationships for a user other than the current user.

Retrieving users

The camel-yammer component provides several endpoints for retrieving users:

URI

Description

Retrieve users in the current user's Yammer network.

View data about the current user.

URI Options for retrieving users

Name

Default Value

Description

useJson

false

Set to true if you want to use raw JSON rather than converting to POJOs.

delay

5000

in milliseconds

consumerKey

null

Consumer Key. Can also be configured on the YammerComponent level instead.

consumerSecret

null

Consumer Secret. Can also be configured on the YammerComponent level instead.

accessToken

null

Access Token. Can also be configured on the YammerComponent level instead.

Using an enricher

It is helpful sometimes (or maybe always in the case of users or relationship consumers) to use an enricher pattern rather than a route initiated with one of the polling consumers in camel-yammer. This is because the consumers will fire repeatedly, however often you set the delay for. If you just want to look up a user's data, or grab a message at a point in time, it is better to call that consumer once and then get one with your route.

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:

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

See Also

Labels
  • No labels