List of Listings

Chapter 1. Discovering Mule

Listing 1.1. Extending FunctionalTestCase to ensure that your configuration works

Listing 1.2. The product registration flow

Chapter 2. Processing messages with Mule

Listing 2.1. The product registration flow, now with logging

Listing 2.2. A flow with an implicit response phase

Listing 2.3. A flow with elements explicitly in the response phase

Listing 2.4. Using a subflow to share a common set of transformers

Listing 2.5. Flow variables can be used to parameterize a subflow.

Listing 2.6. Using a private flow to define a local exception strategy

Listing 2.7. Simple and composite message sources

Listing 2.8. HTTP endpoints with different exchange patterns

Listing 2.9. A simple flow in which execution doesn’t happen as expected

Listing 2.10. Mule endpoints exposing different types of resources

Listing 2.11. Adding a header to the outbound scope adds it to the response

Listing 2.12. A flow that sets a variable and uses it in two places

Listing 2.13. Extracting message attachments with an expression transformer

Listing 2.14. Using an expression to create a dynamic XSLT parameter

Listing 2.15. Logging a value extracted with XPath

Listing 2.16. The validator configuration pattern heavily relies on expressions.

Listing 2.17. Expressions in endpoint URIs can be resolved at runtime by evaluators.

Chapter 3. Working with connectors

Listing 3.1. Using the file transport to move files from one directory to another

Listing 3.2. Posting data with the HTTP transport

Listing 3.3. Using an HTTP inbound endpoint to POST data to a file

Listing 3.4. The BrewService interface

Listing 3.5. The BrewService implementation

Listing 3.6. The Brew domain model

Listing 3.7. The JAX-RS annotated BrewService

Listing 3.8. Expose the brew listing over REST using JAX-RS

Listing 3.9. Using curl to invoke the web service

Listing 3.10. The JAX-WS annotated BrewService interface

Listing 3.11. The JAX-WS annotated BrewService implementation

Listing 3.12. Expose the brew listing over SOAP using CXF

Listing 3.13. Submit expense reports using SOAP

Listing 3.14. Publish expense reports to a JMS topic

Listing 3.15. Logging JMS messages published to a topic

Listing 3.16. Using a JMS selector filter to choose the messages an endpoint receives

Listing 3.17. Synchronously invoke a component using JMS

Listing 3.18. Dispatch cooling emails to a JMS topic

Listing 3.19. Using an SMTP endpoint to send an email

Listing 3.20. Polling a remote FTP directory every hour for new files

Listing 3.21. Sending a file to a remote FTP server

Listing 3.22. Querying a table every hour and sending the results to a JMS topic

Listing 3.23. Using a JDBC outbound endpoint to insert rows into a table

Listing 3.24. Save cooling alerts to a MongoDB collection

Listing 3.25. Query a MongoDB collection over HTTP

Listing 3.26. Using VM endpoints to implement reliability patterns

Listing 3.27. Explicitly configuring a VM queue profile

Listing 3.28. Publishing Twitter status updates from a JMS topic

Listing 3.29. Sampling the Twitter public status update stream

Chapter 4. Transforming data with Mule

Listing 4.1. Encoding a payload in Base64

Listing 4.2. Two styles of references to declare a chain of three transformers

Listing 4.3. Compressing a payload using gzip

Listing 4.4. Uncompressing a payload using gzip

Listing 4.5. Removing properties

Listing 4.6. Removing multiple properties

Listing 4.7. Adding properties with set-property

Listing 4.8. Renaming properties

Listing 4.9. Copying a property from inbound to outbound scope

Listing 4.10. Setting a variable

Listing 4.11. Expression transformer returning a single element

Listing 4.12. Expression transformer returning an array

Listing 4.13. Enriching a message

Listing 4.14. The message enricher can perform multiple enrichments at once.

Listing 4.15. Using a XPath expression to add a property

Listing 4.16. An XSLT transformation with a parameter

Listing 4.17. Using an expression to pass a parameter to XSLT

Listing 4.18. JSON request to query stock availability

Listing 4.19. Querying a JSON document and putting the result in headers

Listing 4.20. JSON representing a business provider of the Prancing Donkey

Listing 4.21. Provider.java

Listing 4.22. PhoneNumber.java

Listing 4.23. EmailAddress.java

Listing 4.24. Creating a mixin

Listing 4.25. Definition of a mixin map

Listing 4.26. Referencing a mixin map

Listing 4.27. Uppercasing a String payload using a Groovy transformer

Listing 4.28. Representing an order as XML

Listing 4.29. Representing an order as CSV

Listing 4.30. Transforming a CSV payload to XML

Listing 4.31. Using a Groovy transform to transform CSV to XML

Chapter 5. Routing data with Mule

Listing 5.1. Routing messages using expressions

Listing 5.2. Routing expense reports based on Content-Type

Listing 5.3. Routing a message based on the type of the payload

Listing 5.4. Routing a message using an XPath expression

Listing 5.5. Java class for an Order

Listing 5.6. Java class for a LineItem

Listing 5.7. XML representation of an Order

Listing 5.8. Using a logical filter

Listing 5.9. Nesting logical filters

Listing 5.10. Ensuring idempotent delivery with the idempotent-message-filter

Listing 5.11. Route to a DLQ

Listing 5.12. Multicast data to SMTP and MongoDB endpoints

Listing 5.13. Scatter/gather IO

Listing 5.14. Asynchronously processing an Order

Listing 5.15. Splitting line items

Listing 5.16. Aggregating line items

Listing 5.17. Routing collections

Listing 5.18. Reliability routing with the until-successful message processor

Listing 5.19. Failure expressions and the until-successful router

Chapter 6. Working with components and patterns

Listing 6.1. A random integer generator service

Listing 6.2. A fixed-seed random integer generator service

Listing 6.3. A Spring-configured, fixed-seed, random integer generator service

Listing 6.4. A method of a component making use of annotations

Listing 6.5. Service limits its resource usage thanks to a pooled component

Listing 6.6. Using a JavaScript component to enrich a message

Listing 6.7. An external Rhino script to add an MD5SUM property to a message

Listing 6.8. Using an externally defined Rhino script to add an MD5 property

Listing 6.9. Prancing Donkey’s shipping cost calculator component

Listing 6.10. Simple service

Listing 6.11. Simple service using a global endpoint

Listing 6.12. Simple service using child elements

Listing 6.13. Service class to be exposed

Listing 6.14. Simple service using JAX-RS

Listing 6.15. Service class to be exposed

Listing 6.16. Simple service using JAX-WS

Listing 6.17. Synchronous bridge

Listing 6.18. Asynchronous bridge

Listing 6.19. Bridge using transformers

Listing 6.20. Basic validator

Listing 6.21. Validating with error expression

Listing 6.22. Validator using references

Listing 6.23. Validator using child elements

Listing 6.24. Basic HTTP proxy

Listing 6.25. HTTP proxy using references

Listing 6.26. HTTP proxy using transformers and response transformers

Listing 6.27. HTTP proxy using cache

Listing 6.28. WS proxy pattern

Listing 6.29. WS proxy using transformers

Listing 6.30. WS proxy using a different WSDL file

Listing 6.31. Validator inheritance

Chapter 7. Integration architecture with Mule

Listing 7.1. Using Mule as a service mediation layer

Listing 7.2. The Customer canonical data model

Listing 7.3. Populate and query records in Salesforce

Listing 7.4. Front-end order submission

Listing 7.5. Back-end order processing

Listing 7.6. Proxying SOAP service requests with the CXF proxy

Listing 7.7. MuleMessage payload before CXF service proxy

Listing 7.8. MuleMessage payload after CXF service proxy

Listing 7.9. Result from vm://brew.lookup

Listing 7.10. Final proxied response

Listing 7.11. Proxying SOAP client requests with the CXF proxy

Chapter 8. Deploying Mule

Listing 8.1. Directory structure of an application that uses the Mule standalone server

Listing 8.2. The default log4j.properties file

Listing 8.3. Flow exporting a service for inter-application communication

Listing 8.4. Flow requesting information in an inter-application communication

Listing 8.5. Configuring an embedded Jetty server

Listing 8.6. Configuring an embedded Jetty SSL server

Listing 8.7. Configuring an embedded Jetty using a config file

Listing 8.8. Configuring an idempotent filter to use Redis as an object store

Chapter 9. Exception handling and transaction management with Mule

Listing 9.1. Using the reconnect strategy

Listing 9.2. Using different strategies for inbound/outbound

Listing 9.3. A working hours–aware retry policy

Listing 9.4. An exhaustible retry policy

Listing 9.5. A policy template

Listing 9.6. Configuring a connector with a custom strategy

Listing 9.7. A locally defined exception strategy

Listing 9.8. A globally defined exception strategy

Listing 9.9. Configuring the default exception strategy

Listing 9.10. Flow with a catch exception strategy

Listing 9.11. Flow with a choice exception strategy

Listing 9.12. Using a JDBC outbound endpoint transactionally

Listing 9.13. Accepting and sending JMS messages transactionally

Listing 9.14. Using ALWAYS_JOIN to join in an existing transaction

Listing 9.15. Using the multicasting router transactionally

Listing 9.16. Making an entire message flow transactional

Listing 9.17. Sending outbound messages to list of endpoints using an XA transaction

Listing 9.18. Using an application server’s transaction manager for XA

Listing 9.19. Implementing a JMS reliability pattern

Chapter 10. Securing Mule

Listing 10.1. Defining an in-memory user service for endpoint authentication

Listing 10.2. Defining an LDAP directory for endpoint authentication

Listing 10.3. Defining a basic HTTP security filter on an HTTP inbound endpoint

Listing 10.4. Using an HTTPS server in a flow

Listing 10.5. Setting authentication in a SOAP service

Listing 10.6. Encrypting the payload of messages using password-based encryption

Listing 10.7. Decrypting PGP-encrypted JMS payloads using a PGP security-filter

Chapter 11. Tuning Mule

Listing 11.1. Report processing in a single flow

Listing 11.2. Report processing in three flows

Listing 11.3. Report processing in a single flow

Chapter 12. Developing with Mule

Listing 12.1. Using the Mule context to access the system configuration

Listing 12.2. Using the Mule context to access the global statistics

Listing 12.3. The registry gives access to all Mule’s moving parts.

Listing 12.4. JMX agents can be looked up in the registry.

Listing 12.5. The client facilitates testing by granting access to a Mule application.

Listing 12.6. Flows can be reached over any protocol via the Mule client.

Listing 12.7. A remote dispatcher agent using the default wire format over TCP

Listing 12.8. The client is the factory for creating remote dispatchers.

Listing 12.9. A remote dispatcher agent using the XML wire format over HTTP

Listing 12.10. Creating a remote dispatcher to connect to a distant Mule over HTTP

Listing 12.11. Bootstrapping an empty Mule application with the client

Listing 12.12. Using Mule’s transports and messaging layers via an empty application

Listing 12.13. Prancing Donkey’s caching interceptor stack defines two interceptors.

Listing 12.14. The cache interceptor uses Ehcache to store and replay payloads.

Listing 12.15. A custom class can be created to receive specific notifications.

Listing 12.16. A custom object can be registered with Mule to receive notifications.

Listing 12.17. Interceptor that rejects events until the context is initialized

Listing 12.18. A flow that relies heavily on Mule’s internal object store

Listing 12.19. An Ehcache-backed listable object store

Listing 12.20. Using custom Ehcache-backed persistence

Listing 12.21. A flow used to asynchronously transform XML messages

Listing 12.22. A connector’s configuration file used during functional tests

Listing 12.23. A functional test case that exercises a flow with JMS endpoints

Listing 12.24. Using pure JMS to test a flow with inbound and outbound JMS endpoints

Listing 12.25. A flow that interacts with a remote service

Listing 12.26. A flow that interacts with a remote service via a global endpoint

Listing 12.27. A test configuration file with in-memory transports and service stubs

Listing 12.28. A functional test that uses a stubbed-out HTTP service

Listing 12.29. A latch suspends the test execution until a message is received

Listing 12.30. Using the test component to simulate exceptions

Listing 12.31. Using the test component to simulate slowness

Listing 12.32. A flow that logs all message meta information

Chapter 13. Writing custom cloud connectors and processors

Listing 13.1. Class annotated to create a Mule cloud connector

Listing 13.2. Class annotated to create a Mule module

Listing 13.3. Using @Connect and @Disconnect

Listing 13.4. Using connection arguments in the config element

Listing 13.5. Using connection arguments as processor attributes

Listing 13.6. The cache interceptor using DevKit

Chapter 14. Augmenting Mule with orthogonal technologies

Listing 14.1. jBPM process definition for order processing

Listing 14.2. Using jBPM as a BPM engine with Mule

Listing 14.3. The Esper configuration

Listing 14.4. The Esper configuration

Listing 14.5. Automatically creating Salesforce cases using Twitter

Listing 14.6. Customer loyalty rules

Listing 14.7. Configuring Drools in Mule

Listing 14.8. Java class for an Alert

Listing 14.9. The Alert routing DRL file

Listing 14.10. Configuring Drools in Mule

Listing 14.11. The poll message processor repeatedly fetches Twitter’s public timeline

Listing 14.12. Using Quartz’s cron expression to fire an event once per month

Appendix D. A sample Mule application

Listing D.1. The Mule application configuration

Listing D.2. The ProductImportFunctionalTestCase implementation

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset