Hipchat Component

Available as of Camel 2.15.0

The Hipchat component supports producing and consuming messages from/to Hipchat service.

Prerequisites

You must have a valid Hipchat user account and get a personal access token that you can use to produce/consume messages.

URI Format

hipchat://[host][:port]?options

You can append query options to the URI in the following format, ?options=value&option2=value&...

URI Options

Name

Default Value

Context

RequiredProducer/Consumer

Description

protocol

null

Shared

YesBoth

Default protocol to connect to the Hipchat server such as http or https

hostnullSharedYesBothThe API host of the Hipchat to connect to, such as api.hipchat.com
port80SharedNoBothThe port to connect to on the Hipchat host

authToken

null

Shared

YesBothAuthorization token(personal access token) obtained from Hipchat

 

delay5000SharedNoConsumerThe poll interval in millisec for consuming messages from consumeUsers provided. Please read about rate limits before decreasing this.

consumeUsers

null

Shared

NoConsumer

Comma separated list of user @Mentions or emails whose messages to the owner of authToken must be consumed

Scheduled Poll Consumer

This component implements the ScheduledPollConsumer. Only the last message from the provided 'consumeUsers' are retrieved and sent as Exchange body. If you do not want the same message to be retrieved again when there are no new messages on next poll then you can add the idempotent consumer as shown below. All the options on the ScheduledPollConsumer can also be used for more control on the consumer.

@Override
public void configure() throws Exception {
 String hipchatEndpointUri = "hipchat://?authToken=XXXX&consumeUsers=@Joe,@John";
 from(hipchatEndpointUri)
  .idempotentConsumer(
    simple("${in.header.HipchatMessageDate} ${in.header.HipchatFromUser}"),
    MemoryIdempotentRepository.memoryIdempotentRepository(200)
  )
  .to("mock:result");
}

Message headers set by the Hipchat consumer

Header

Constant

Type

Description

HipchatFromUserHipchatConstants.FROM_USERStringThe body has the message that was sent from this user to the owner of authToken
HipchatMessageDateHipchatConstants.MESSAGE_DATEStringThe date message was sent. The format is ISO-8601 as present in the Hipchat response.
HipchatFromUserResponseStatusHipchatConstants.FROM_USER_RESPONSE_STATUS StatusLineThe status of the API response received.

Hipchat Producer

Producer can send messages to both Room's and User's simultaneously. The body of the exchange is sent as message. Sample usage is shown below. Appropriate headers needs to be set.

@Override
 public void configure() throws Exception {
  String hipchatEndpointUri = "hipchat://?authToken=XXXX";
  from("direct:start")
   .to(hipchatEndpointUri)
   .to("mock:result");
 }

Message headers evaluated by the Hipchat producer

Header

Constant

Type

Description

HipchatToUserHipchatConstants.TO_USERStringThe Hipchat user to which the message needs to be sent.
HipchatToRoomHipchatConstants.TO_ROOMStringThe Hipchat room to which the message needs to be sent.
HipchatMessageFormatHipchatConstants.MESSAGE_FORMATStringValid formats are 'text' or 'html'. Default: 'text'
HipchatMessageBackgroundColorHipchatConstants.MESSAGE_BACKGROUND_COLORStringValid color values are 'yellow', 'green', 'red', 'purple', 'gray', 'random'. Default: 'yellow' (Room Only) 
HipchatTriggerNotificationHipchatConstants.TRIGGER_NOTIFYStringValid values are 'true' or 'false'. Whether this message should trigger a user notification (change the tab color, play a sound, notify mobile phones, etc). Default: 'false' (Room Only)

Message headers set by the Hipchat producer

Header

Constant

Type

Description

HipchatToUserResponseStatusHipchatConstants.TO_USER_RESPONSE_STATUSStatusLineThe status of the API response received when message sent to the user.
HipchatFromUserResponseStatusHipchatConstants.TO_ROOM_RESPONSE_STATUSStatusLineThe status of the API response received when message sent to the room.

Dependencies

Maven users will need to add the following dependency to their pom.xml.

pom.xml
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-hipchat</artifactId>
    <version>${camel-version}</version>
</dependency>

where ${camel-version} must be replaced by the actual version of Camel (2.15.0 or higher)

  • No labels