HornetQ User Manual
Putting the buzz in messaging
by Clebert Suconic (Red Hat, Inc.), Andy Taylor (Red Hat, Inc.), Tim
Fox (Red Hat, Inc.), Jeff Mesnil (Red Hat, Inc.), Howard Gao (Red
Hat, Inc.), Francisco Borges, and Justin Bertram (Red Hat, Inc.)
iii
1. Legal Notice ................................................................................................................ 1
2. Preface ......................................................................................................................... 3
3. Project Information ...................................................................................................... 5
3.1. Software Download ............................................................................................. 5
3.2. Project Information .............................................................................................. 5
4. Messaging Concepts ................................................................................................... 7
4.1. Messaging Concepts ........................................................................................... 7
4.2. Messaging styles ................................................................................................ 7
4.2.1. The Message Queue Pattern .................................................................... 8
4.2.2. The Publish-Subscribe Pattern .................................................................. 8
4.3. Delivery guarantees ............................................................................................ 9
4.4. Transactions ....................................................................................................... 9
4.5. Durability ............................................................................................................ 9
4.6. Messaging APIs and protocols ............................................................................ 9
4.6.1. Java Message Service (JMS) .................................................................. 10
4.6.2. System specific APIs .............................................................................. 10
4.6.3. RESTful API .......................................................................................... 10
4.6.4. STOMP ................................................................................................. 10
4.6.5. AMQP ................................................................................................... 11
4.7. High Availability ................................................................................................ 11
4.8. Clusters ............................................................................................................ 11
4.9. Bridges and routing ........................................................................................... 11
5. Architecture ............................................................................................................... 13
5.1. Core Architecture .............................................................................................. 13
5.2. HornetQ embedded in your own application ....................................................... 15
5.3. HornetQ integrated with a JEE application server ................................................ 15
5.4. HornetQ stand-alone server ............................................................................... 16
6. Using the Server ........................................................................................................ 19
6.1. Starting and Stopping the standalone server ....................................................... 19
6.2. Server JVM settings .......................................................................................... 19
6.3. Server classpath ............................................................................................... 20
6.4. Library Path ...................................................................................................... 20
6.5. System properties ............................................................................................. 20
6.6. Configuration files ............................................................................................. 20
6.7. JBoss Microcontainer Beans File ....................................................................... 22
6.8. JBoss AS4 MBean Service. ............................................................................... 24
6.9. The main configuration file. ............................................................................... 26
7. Using JMS ................................................................................................................. 27
7.1. A simple ordering system .................................................................................. 27
7.2. JMS Server Configuration .................................................................................. 27
7.3. Connection Factory Types ................................................................................. 28
7.4. JNDI configuration ............................................................................................ 29
7.5. The code .......................................................................................................... 30
7.6. Directly instantiating JMS Resources without using JNDI ..................................... 32
HornetQ User Manual
iv
7.7. Setting The Client ID ........................................................................................ 33
7.8. Setting The Batch Size for DUPS_OK ................................................................ 34
7.9. Setting The Transaction Batch Size ................................................................... 34
8. Using Core ................................................................................................................. 35
8.1. Core Messaging Concepts ................................................................................ 35
8.1.1. Message ................................................................................................ 35
8.1.2. Address ................................................................................................. 36
8.1.3. Queue ................................................................................................... 36
8.1.4. ServerLocator ........................................................................................ 36
8.1.5. ClientSessionFactory .............................................................................. 37
8.1.6. ClientSession ......................................................................................... 37
8.1.7. ClientConsumer ...................................................................................... 37
8.1.8. ClientProducer ....................................................................................... 37
8.2. A simple example of using Core ........................................................................ 38
9. Mapping JMS Concepts to the Core API ................................................................... 39
10. The Client Classpath ............................................................................................... 41
10.1. HornetQ Core Client ........................................................................................ 41
10.2. JMS Client ...................................................................................................... 41
10.3. JMS Client with JNDI ...................................................................................... 41
11. Examples ................................................................................................................. 43
11.1. JMS Examples ................................................................................................ 43
11.1.1. JMS AeroGear ..................................................................................... 43
11.1.2. Applet .................................................................................................. 43
11.1.3. Application-Layer Failover ..................................................................... 43
11.1.4. Core Bridge Example ........................................................................... 44
11.1.5. Browser ............................................................................................... 44
11.1.6. Client Kickoff ........................................................................................ 44
11.1.7. Client side failover listener .................................................................... 44
11.1.8. Client-Side Load-Balancing ................................................................... 44
11.1.9. Clustered Durable Subscription ............................................................. 44
11.1.10. Clustered Grouping ............................................................................. 44
11.1.11. Clustered Queue ................................................................................ 44
11.1.12. Clustering with JGroups ...................................................................... 45
11.1.13. Clustered Standalone .......................................................................... 45
11.1.14. Clustered Static Discovery .................................................................. 45
11.1.15. Clustered Static Cluster One Way ....................................................... 45
11.1.16. Clustered Topic .................................................................................. 45
11.1.17. Message Consumer Rate Limiting ....................................................... 45
11.1.18. Dead Letter ........................................................................................ 45
11.1.19. Delayed Redelivery ............................................................................. 46
11.1.20. Divert ................................................................................................. 46
11.1.21. Durable Subscription ........................................................................... 46
11.1.22. Embedded .......................................................................................... 46
11.1.23. Embedded Simple .............................................................................. 46
v
11.1.24. Message Expiration ............................................................................ 46
11.1.25. HornetQ Resource Adapter example .................................................... 47
11.1.26. HTTP Transport .................................................................................. 47
11.1.27. Instantiate JMS Objects Directly .......................................................... 47
11.1.28. Interceptor .......................................................................................... 47
11.1.29. JAAS ................................................................................................. 47
11.1.30. JMS Auto Closable ............................................................................. 47
11.1.31. JMS Completion Listener .................................................................... 47
11.1.32. JMS Bridge ........................................................................................ 48
11.1.33. JMS Context ...................................................................................... 48
11.1.34. JMS Shared Consumer ....................................................................... 48
11.1.35. JMX Management .............................................................................. 48
11.1.36. Large Message .................................................................................. 48
11.1.37. Last-Value Queue ............................................................................... 48
11.1.38. Management ...................................................................................... 48
11.1.39. Management Notification ..................................................................... 49
11.1.40. Message Counter ............................................................................... 49
11.1.41. Message Group .................................................................................. 49
11.1.42. Message Group .................................................................................. 49
11.1.43. Message Priority ................................................................................. 49
11.1.44. Multiple Failover ................................................................................. 49
11.1.45. Multiple Failover Failback .................................................................... 50
11.1.46. No Consumer Buffering ....................................................................... 50
11.1.47. Non-Transaction Failover With Server Data Replication ......................... 50
11.1.48. Paging ............................................................................................... 50
11.1.49. Pre-Acknowledge ................................................................................ 50
11.1.50. Message Producer Rate Limiting ......................................................... 51
11.1.51. Proton Qpid ........................................................................................ 51
11.1.52. Proton Ruby ....................................................................................... 51
11.1.53. Queue ................................................................................................ 51
11.1.54. Message Redistribution ....................................................................... 51
11.1.55. Queue Requestor ............................................................................... 51
11.1.56. Queue with Message Selector ............................................................. 51
11.1.57. Reattach Node example ...................................................................... 51
11.1.58. Replicated Failback example ............................................................... 51
11.1.59. Replicated Failback static example ...................................................... 52
11.1.60. Replicated multiple failover example .................................................... 52
11.1.61. Replicated Failover transaction example .............................................. 52
11.1.62. Request-Reply example ...................................................................... 52
11.1.63. Rest example ..................................................................................... 52
11.1.64. Scheduled Message ........................................................................... 52
11.1.65. Security .............................................................................................. 52
11.1.66. Send Acknowledgements .................................................................... 52
11.1.67. Spring Integration ............................................................................... 52
评论0