Professor-X and Jean Grey for the rescue of your integration setbacks!

ESBs are dead!

Really?

What is a Connector?

Aaah Oki, This is the thing. I know it’s a bit hard to digest an alien word all of a sudden. Lisa, it’s a word used by developers in Integration.

Writing a Connector With Project-X Using a Java Library

You need to create a new project using UltraStudio, and all the coding will be done in the source directory under com.acme.esb package.

Figure 1: Project structure.
Figure 2: The initial look of the Egress connector implementation.
<!-- Twilio Java Library Dependency-->
<dependency>
<groupId>com.twilio.sdk</groupId>
<artifactId>twilio</artifactId>
<version>7.15.6</version>
</dependency>
  1. Username: Your username (Account SID) to access your Twilio Account
  2. Password: Your password (Auth Token) to access your Twilio Account
@Parameter(displayName = "User Name", 
inputType = InputType.TEXT_BOX,
placeHolder = "Twilio Account User Name",
description = "Twilio Account User Name",
propertyName = "userName")
private String userName;

@Parameter(displayName = "Password",
inputType = InputType.TEXT_BOX,
placeHolder = "Twilio Account Password",
description = "Twilio Account Password",
propertyName = "password")
private String password;
Twilio.init(userName, password);
<Logger name="com.acme.esb" level="INFO"/>

Writing Connector Operations Using Project-X

You now have to focus on implementing your Connector Operation related to sending messages.

  1. Your phone number: your Twilio number which you can find on your Twilio Console (Phone Numbers)
  2. Phone number to send the message: any phone number on the list of Verified Caller IDs.
  3. Message Body: what you want to send as a message.
@Parameter(displayName = "From Phone Number", 
inputType = InputType.TEXT_BOX,
placeHolder = "Insert your phone number",
description = "Your phone number",
propertyName = "fromNumber",
order = 1)
private String fromNumber;

@Parameter(displayName = "To Phone number",
inputType = InputType.TEXT_BOX,
placeHolder = "Insert recipient's phone number ",
description = "Phone number to send the message",
propertyName = "toNumber",
order = 2)
private String toNumber;

@Parameter(displayName = "Message Body",
inputType = InputType.TEXT_BOX,
placeHolder = "Insert the message body",
description = "Message Body",
propertyName = "userName",
order = 3)
private String messageBody;
@Override
public XMessageContext prepareMessage(XMessageContext messageContext) {
Message message = Message
.creator(new PhoneNumber(fromNumber), new PhoneNumber(toNumber),
messageBody ).create();
logger.info(1,"Message Status : {} ", message.getStatus());
messageContext.getMessage().addMessageProperty("Response", message.getStatus());
return messageContext;
}

Testing Twilio Connector

First of all, you need to build your project. If you are more familiar with the command line, run mvn clean install and build your project. Or else, you can do this through the IntelliJ IDEA UI, Build > Build Project (or Ctrl+F9).

Figure 6: Flow diagram
Figure 7: Configuring HTTP NIO Ingress Connector
Figure 8: Configuring Twilio Egress Connector
Figure 9: Configuring Send Message Connector Operation
Figure 12: Creating an HTTP Client

Yeyyyyy! Congrats! You finally did it!

See how our Professor-X and Jean Grey saved your day!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hasangi Kahaduwa

Hasangi Kahaduwa

Software Engineer at General Motors