Skip to main content
Skip table of contents

Working with channels

Learning objectives
This lesson walks you through the steps to create an HTTP channel, then use it to send a request and receive a response. By the end of this module, you should know:

  • What role channels play in integration.
  • About the different types of channels.
  • How to create an HTTP channel in NexJ Studio.
  • How to create an HTTP message in script.

  • How to call an HTTP channel in script.

  • How to inspect response headers in script.

Key concepts
The goal of integration is to share information between different systems. Channels are a key component of the integration layer. They are what you send and receive messages to and from. Different channel types isolate differences between protocols so that, regardless of what protocol you are using, you will always use a common send/receive interface.

Channel types supported by the platform include:

  • File
    Send and receive files from a set of directories.
  • HTTP
    Send and receive messages through an HTTP channel as a client or server.
  • Mail
    Send and receive email messages through a mail server.
  • Message Queue
    Send and receive messages between client applications using JMS or MQ.
  • Object Queue
    Send and receive messages between internal applications using the advanced capabilities of Object Queues.
  • TCP
    Send and receive messages through a TCP channel as a client or server.
  • UDP
    Send and receive messages through a UDP channel as a client or server.
  • Kafka
    Sends a message to a Kafka server.

Integration channels interact with external systems over a Send and Receive interface. 

Channel interactions are message based and can be asynchronous, meaning that once a message has been sent, the sender does not wait for a response before continuing to the next instruction.

Channels are configured and bound to physical communication addresses on each system through connections. Once deployed through a connection, channels can be accessed at http://<serverRoot>/channel/<channelName>. Channels can be bound to one or more services, which process any messages received on the channel.

Creating an HTTP channel

Let's create a new HTTP channel called training:http:

Learning activity

To create this new HTTP channel:

  1. In the Integration layer of NexJ Studio, select the Channels tab.
  2. Right-click the list area inside the tab and select New Channel.
  3. In the New Channel dialog, specify the following values:
    • Name: training:http
    • Channel Type:  HTTP
  4. Click Finish to close the New Channel dialog.
    The newly created channel opens in an editor window.

Writing a send script

In this section, you will use script to create an HTTP message, send and receive the message through the training:http channel, and inspect the response.

The first statement in the script creates the message using a URL. The second statement sends an HTTP request to the training:http channel. Final statements display information from the HTTP response headers.

Learning activity

To create the script:

  1. Open an existing scratchpad or create a new scratchpad using File > New > Scratchpad.
  2. Enter the following code in the scratchpad:

    ; Create the request message
    (define req
    		(: :class "HTTP")
    		(: url "")
    		(: method "GET")
    ; Send the request, receive the response
    (define resp
    	(integration-send-receive req "training:http" ())
    ; Inspect the response
    (logger'info "HEADERS:" (resp'headers))
    (logger'info "BODY:" (resp'body))
    (logger'info "Length of BODY:"
    ; Iterate over the headers
    	(lambda (h)
    		(logger'info "HEADER:" h "=>" ((resp'headers) h))

Using the script to test the HTTP channel

Use the Console to run the script you created in the scratchpad.

Learning activity

  1. To see more of the back and forth, stop your server, set the Console's default log level to DEBUG, and restart the server:
    1. In the Run menu, select Run Scheme Console > Scheme Console Settings. The Preferences dialog opens.
    2. Set the Default log level to DEBUG.
    3. Click Apply and Close to accept the changes and close the Preferences dialog.
  2. Click the Run Scheme Console button 

     in the toolbar to run the Console. The new Console starts in the Console view.

  3. In the Console, execute each of the statements from the scratchpad individually and inspect the results.

  4. When you are finished, stop the Scheme Console by clicking the Terminate button


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.