Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Using Microsoft .NET in WebSphere Message Broker V8: Part 4: Using the .NETCompute node for exception handling

Ben Thompson (bthomps@uk.ibm.com), Consulting IT Specialist, IBM
Author photo
Ben Thompson is a Consulting IT Specialist working on the WebSphere Message Broker development team at the IBM Hursley Software Lab in the UK. He is currently working on the design and implementation of .NET support in Message Broker. In the past, he has worked for IBM Software Services for WebSphere designing and implementing WebSphere solutions for IBM customers worldwide. You can contact Ben at bthomps@uk.ibm.com.
(An IBM developerWorks Contributing Author)
Matthew Golby-Kirk (mgk@uk.ibm.com), Software Developer, IBM
Matthew Golby-Kirk photo
Matthew Golby-Kirk is a software developer working on the WebSphere Message Broker development team at the IBM Hursley Software Lab in the UK. He works on the design and implementation of the HTTP and Web services support, along with the ESQL language run time in WebSphere Message Broker. You can contact Matthew at mgk@uk.ibm.com.

Summary:  This series of four tutorials demonstrates the new support for Microsoft .NET in WebSphere Message Broker V8. Part 4 shows you how to use the .NETCompute node for exception handling, using a scenario that builds in complexity as additional exception conditions are deliberately produced and then handled. Readers should be familiar with either Microsoft .NET or WebSphere Message Broker, but need not be familiar with both.

View more content in this series

Date:  22 Feb 2012
Level:  Intermediate

Comments:  

Generating a message flow exception

  1. Assuming that the WebSphere Message Broker Toolkit has not yet been started, from the Start menu, choose Start => Programs => IBM WebSphere Message Broker Toolkit => IBM WebSphere Message Broker Toolkit 8.0 => WebSphere Message Broker Toolkit 8.0. You will be asked for the location of a workspace -- the rest of this tutorial assumes that you are using C:\student\DOTNET\lab_exceptions\workspace.
  2. Close the Welcome screen and from your empty workspace, launch the Quick Start wizard: Click Start by creating an application as shown below in the red box. If you have chosen to use your existing workspace, you can also launch the Quick Start menu by clicking the New link at the top of the Broker Development view on the left:

    New application
  3. The Quick Start wizard requires an application name. Specify App_DotNet_Exceptions and click Finish:

    New Application wizard
  4. In the Application Development window, click New underneath the application you just created, and then on the pop-up New Artifact window, select Message Flow, as shown below:

    New Artifact popup
  5. In the New Message Flow wizard that opens, specify a Message Flow name of MyFlow, and then click Finish:

    NewFlow wizard
  6. The message flow will appear with an empty canvas. Create the contents of a simple message flow by dragging and dropping two nodes onto the flow canvas. Take an MQ Input node from the WebSphere MQ drawer, and a Throw node from the Construction drawer of the palette. Rename the MQ Input node DOTNET.EXCEPTIONS.IN and set the Basic property of Queue name to the same value. Wire the Out terminal of the MQ Input node to the In terminal of the Throw node. The resulting message flow should look like this:

    Flow design
    The Basic properties panel of the MQInput node, where the queue name is configured, should look like this:

    Basic Properties panel of MQInput node
  7. Configure the Throw node's basic property of Message text to a value such as This is a deliberate exception!:

    Throw node
  8. Save the message flow: Type Ctrl-S or select File => Save.
  9. To test the message flow, you need to define an input queue. Assuming that WebSphere Message Broker Explorer has not yet been started, from the Start menu, choose Start => Programs => IBM WebSphere Message Broker 8.0.0.0 => IBM WebSphere Message Broker Explorer. This tutorial assumes your user ID has permissions to administer WebSphere MQ. This tutorial also assumes that you have set up a runtime broker using the default configuration, which provides a message broker named MB8BROKER associated with a queue manager named MB8QMGR. For more information on the default configuration, see Creating the Default Configuration in the Message Broker information center. Right-click the Queues folder underneath the queue manager MB8QMGR and select New => Local Queue:

    Create queues
  10. In the New Local Queue wizard, specify the Name as DOTNET.EXCEPTIONS.IN and click Finish:

    New Local Queue Wizard
  11. For the purpose of the later examples, create another two queues using the same New Local Queue wizard. Name the queues DOTNET.EXCEPTIONS.CATCH and DOTNET.EXCEPTIONS.OUT. The Message Broker Explorer view of the queue manager should then look like this:

    Local queues
  12. Now return to the WebSphere Message Broker Toolkit and the message flow MyFlow that you constructed earlier. This simple example demonstrates what message flows do when they encounter an exception. The Throw node is a simple way for a flow developer to generate an exception. When an input message reaches the Throw node, an exception is created and the propagation flows backwards through the flow until the exception is caught. In this simple flow, the Catch terminal of the MQInput node has not been wired, so when the rollback occurs, the message is backed out to the input queue's backout queue if one exists, or placed on the queue manager's dead letter queue if one is defined. If neither of these options is possible, then the message is discarded if non-persistent, or left back on the input queue if persistent, and the exception is recorded in the Windows Application Log. To demonstrate this behaviour, right-click the MQInput node and select Test:

    Test message flow named MyFlow
  13. Click OK to confirm that you are happy to deploy the message flow within an application:

    Application deployment confirmation
  14. A test client file will be created named App_DotNet_Exceptions.mbtest. Type any input message (the text is not important) into the main box, then click Send Message in the bottom right corner:

    App_DotNet_Exceptions.mbtest
  15. The Select Deployment Location wizard opens. Keep the default settings and click Finish, as shown below:

    Select Deployment Location wizard
  16. After a few seconds, the message flow will deploy and the input message will be sent, exercising the flow:

    Result of Test 1
  17. Open the Windows Event Viewer and in the Application Log, you should see information messages showing the deployment that you just executed. Check the three most recent entries. The first error (BIP2628) shows the exception being caught at the MQInput after the flow rolled back. The information event (BIP3001) explains what caused the rollback (the deliberate exception thrown by the Throw node). The last error message (BIP2648) indicates that the backout threshold has been reached, and therefore the message will be discarded:

    Windows Event Log 1

This section of the tutorial showed a simple exception being deliberately thrown from a message flow. In the next section, you will catch this exception using the Catch terminal of the MQInput node, and then in later sections you will explore the .NETCompute node's ability to generate and catch exceptions.

2 of 10 | Previous | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=795296
TutorialTitle=Using Microsoft .NET in WebSphere Message Broker V8: Part 4: Using the .NETCompute node for exception handling
publish-date=02222012
author1-email=bthomps@uk.ibm.com
author1-email-cc=
author2-email=mgk@uk.ibm.com
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).