torquebox-messaging 2.0.0.beta3-java → 2.0.0.cr1-java

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gem_hook.rb CHANGED
@@ -28,6 +28,7 @@ require 'torquebox/messaging/session'
28
28
 
29
29
  require 'torquebox/messaging/message'
30
30
  require 'torquebox/messaging/json_message'
31
+ require 'torquebox/messaging/clojure_message'
31
32
  require 'torquebox/messaging/text_message'
32
33
  require 'torquebox/messaging/marshal_base64_message'
33
34
  require 'torquebox/messaging/marshal_message'
@@ -44,3 +45,5 @@ require 'torquebox/messaging/message_processor'
44
45
  require 'torquebox/messaging/task'
45
46
  require 'torquebox/messaging/backgroundable'
46
47
  require 'torquebox/messaging/processor_wrapper'
48
+
49
+ require 'torquebox/messaging/datamapper_marshaling.rb'
@@ -66,13 +66,12 @@ module TorqueBox
66
66
  end
67
67
 
68
68
  def method_added(method)
69
+ super
69
70
  method = method.to_s
70
71
  if @__backgroundable_methods &&
71
72
  @__backgroundable_methods[method] &&
72
73
  !@__backgroundable_methods[method][:backgrounding]
73
74
  __enable_backgrounding(method)
74
- else
75
- super
76
75
  end
77
76
  end
78
77
 
@@ -0,0 +1,37 @@
1
+ # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
+
18
+ require 'clj'
19
+
20
+ module TorqueBox
21
+ module Messaging
22
+ class ClojureMessage < Message
23
+ ENCODING = :clojure
24
+ JMS_TYPE = :text
25
+
26
+ def encode(message)
27
+ @jms_message.text = Clojure.dump(message)
28
+ end
29
+
30
+ def decode
31
+ Clojure.parse(@jms_message.text) unless @jms_message.text.nil?
32
+ end
33
+ end
34
+
35
+ Message.register_encoding( ClojureMessage )
36
+ end
37
+ end
@@ -35,7 +35,7 @@ module TorqueBox
35
35
 
36
36
  def with_new_connection(options, &block)
37
37
  client_id = options[:client_id]
38
- connection = create_connection( options[:naming_host], options[:naming_port] )
38
+ connection = create_connection( options )
39
39
  connection.client_id = client_id if client_id
40
40
  connection.start
41
41
  begin
@@ -46,20 +46,24 @@ module TorqueBox
46
46
  return result
47
47
  end
48
48
 
49
- def create_connection(host, port)
50
- host ||= "localhost"
51
- port ||= 5445
49
+ def create_connection(options)
50
+ host = options[:host] || "localhost"
51
+ port = options[:port] || 5445
52
+ username = options[:username]
53
+ password = options[:password]
52
54
  if !@internal_connection_factory
53
- # try to connect to HornetQ directly
54
- connect_opts = { "host" => host, "port" => port }
55
- transport_config =
56
- org.hornetq.api.core.TransportConfiguration.new("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory",
57
- connect_opts)
58
- @internal_connection_factory =
59
- org.hornetq.api.jms.HornetQJMSClient.createConnectionFactoryWithoutHA( org.hornetq.api.jms::JMSFactoryType::CF, transport_config )
55
+ @internal_connection_factory = create_connection_factory( host, port )
60
56
  end
61
57
 
62
- Connection.new( @internal_connection_factory.create_connection )
58
+ Connection.new( @internal_connection_factory.create_connection( username, password ) )
59
+ end
60
+
61
+ def create_connection_factory(host, port)
62
+ connect_opts = { "host" => host, "port" => port }
63
+ transport_config =
64
+ org.hornetq.api.core.TransportConfiguration.new("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory",
65
+ connect_opts)
66
+ org.hornetq.api.jms.HornetQJMSClient.createConnectionFactoryWithoutHA( org.hornetq.api.jms::JMSFactoryType::CF, transport_config )
63
67
  end
64
68
 
65
69
 
@@ -0,0 +1,42 @@
1
+ # Copyright 2008-2012 Red Hat, Inc, and individual contributors.
2
+ #
3
+ # This is free software; you can redistribute it and/or modify it
4
+ # under the terms of the GNU Lesser General Public License as
5
+ # published by the Free Software Foundation; either version 2.1 of
6
+ # the License, or (at your option) any later version.
7
+ #
8
+ # This software is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this software; if not, write to the Free
15
+ # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16
+ # 02110-1301 USA, or see the FSF site: http://www.fsf.org.
17
+
18
+ # DataMapper::Resource uses Procs for default values and Marshal.dump
19
+ # does not like that. So, when sending or receiving a DataMapper::Resource
20
+ # we need to override _dump and _load to just serialize the ID and
21
+ # class name of the resource, and use Resource.get to _load it.
22
+ module TorqueBox
23
+ module Messaging
24
+ module DataMapper
25
+
26
+ def self.included(base)
27
+ base.extend(ClassMethods)
28
+ end
29
+
30
+ def _dump( level )
31
+ [id, self.class].join(':')
32
+ end
33
+
34
+ module ClassMethods
35
+ def _load( string )
36
+ id, clazz = string.split(':')
37
+ Kernel.const_get(clazz).get(id)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
Binary file
@@ -1,14 +1,14 @@
1
1
  module TorqueboxMessaging
2
- VERSION = '2.0.0.beta3'
3
- MAVEN_VERSION = '2.0.0.beta3'
2
+ VERSION = '2.0.0.cr1'
3
+ MAVEN_VERSION = '2.0.0.cr1'
4
4
  end
5
5
  begin
6
6
  require 'java'
7
7
  require File.dirname(__FILE__) + '/torquebox-messaging.jar'
8
8
  require File.dirname(__FILE__) + '/jboss-jms-api_1.1_spec-1.0.0.Final.jar'
9
9
  require File.dirname(__FILE__) + '/jboss-transaction-api_1.1_spec-1.0.0.Final.jar'
10
- require File.dirname(__FILE__) + '/hornetq-core-2.2.10.Final.jar'
11
- require File.dirname(__FILE__) + '/hornetq-jms-2.2.10.Final.jar'
10
+ require File.dirname(__FILE__) + '/hornetq-core-2.2.11.Final.jar'
11
+ require File.dirname(__FILE__) + '/hornetq-jms-2.2.11.Final.jar'
12
12
  require File.dirname(__FILE__) + '/netty-3.2.6.Final.jar'
13
13
  rescue LoadError
14
14
  puts 'JAR-based gems require JRuby to load. Please visit www.jruby.org.'
@@ -19,7 +19,7 @@ describe TorqueBox::Messaging::Backgroundable do
19
19
  before(:all) do
20
20
  @util = TorqueBox::Messaging::Backgroundable::Util
21
21
  end
22
-
22
+
23
23
  describe "always_background" do
24
24
  it "should be able to handle mutliple methods" do
25
25
  MyTestModel.always_background :foo, :bar
@@ -0,0 +1,25 @@
1
+ require 'torquebox/messaging/datamapper_marshaling'
2
+
3
+ class MyTestDataMapperModel
4
+ include TorqueBox::Messaging::DataMapper
5
+ def id ; 100 end
6
+ end
7
+
8
+ describe TorqueBox::Messaging::DataMapper do
9
+
10
+ describe "DataMapper::Resource" do
11
+ it "should _dump as a string with the ID and class name" do
12
+ model = MyTestDataMapperModel.new
13
+ id, clazz = model._dump(-1).split(':')
14
+ clazz.should == model.class.name
15
+ id.should == "100"
16
+ end
17
+
18
+ it "should call Resource.get with the id on Marshal.load" do
19
+ MyTestDataMapperModel.should_receive(:get).with("100")
20
+ Marshal.load(Marshal.dump(MyTestDataMapperModel.new))
21
+ end
22
+ end
23
+
24
+ end
25
+
@@ -10,6 +10,10 @@ java_import org.hornetq.jms.server.impl.JMSServerManagerImpl
10
10
 
11
11
  describe TorqueBox::Messaging::Destination do
12
12
 
13
+ after(:each) do
14
+ TorqueBox::Registry.registry.clear
15
+ end
16
+
13
17
  it "should return its name for to_s" do
14
18
  queue = TorqueBox::Messaging::Queue.new("/queues/foo")
15
19
  queue.name.should == "/queues/foo"
@@ -37,8 +41,28 @@ describe TorqueBox::Messaging::Destination do
37
41
  end
38
42
 
39
43
  it "should initialize with connect options if given" do
40
- queue = TorqueBox::Messaging::Queue.new("/queues/foo", :naming_host => "bart")
41
- queue.connect_options[:naming_host].should == "bart"
44
+ queue = TorqueBox::Messaging::Queue.new("/queues/foo", :host => "bart")
45
+ queue.connect_options[:host].should == "bart"
46
+ end
47
+
48
+ it "should connect with host and port if given" do
49
+ factory = mock("factory")
50
+ connection = mock("connection").as_null_object
51
+ factory.stub(:create_connection).and_return(connection)
52
+
53
+ queue = TorqueBox::Messaging::Queue.new("/queues/foo", :host => "bar", :port => 123)
54
+ queue.connection_factory.should_receive(:create_connection_factory).with("bar", 123).and_return(factory)
55
+ queue.with_session { }
56
+ end
57
+
58
+ it "should connect with username and password if given" do
59
+ factory = mock("factory")
60
+ connection = mock("connection").as_null_object
61
+ factory.should_receive(:create_connection).with("ham", "biscuit").and_return(connection)
62
+ TorqueBox::Registry.merge!("connection-factory" => factory)
63
+
64
+ queue = TorqueBox::Messaging::Queue.new("/queues/foo", :username => "ham", :password => "biscuit")
65
+ queue.with_session { }
42
66
  end
43
67
 
44
68
  it "should start and stop a queue" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: torquebox-messaging
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 2.0.0.beta3
5
+ version: 2.0.0.cr1
6
6
  platform: java
7
7
  authors:
8
8
  - The TorqueBox Team
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-24 00:00:00 Z
13
+ date: 2012-03-02 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: torquebox-core
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - "="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.0.0.beta3
23
+ version: 2.0.0.cr1
24
24
  type: :runtime
25
25
  version_requirements: *id001
26
26
  - !ruby/object:Gem::Dependency
@@ -31,20 +31,31 @@ dependencies:
31
31
  requirements:
32
32
  - - "="
33
33
  - !ruby/object:Gem::Version
34
- version: 2.0.0.beta3
34
+ version: 2.0.0.cr1
35
35
  type: :runtime
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
38
- name: rspec
38
+ name: clj
39
39
  prerelease: false
40
40
  requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.0.5.6
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
41
52
  none: false
42
53
  requirements:
43
54
  - - "="
44
55
  - !ruby/object:Gem::Version
45
56
  version: 2.7.0
46
57
  type: :development
47
- version_requirements: *id003
58
+ version_requirements: *id004
48
59
  description: ""
49
60
  email:
50
61
  - torquebox-dev@torquebox.org
@@ -60,45 +71,48 @@ files:
60
71
  - lib/torquebox-messaging.rb
61
72
  - lib/jboss-jms-api_1.1_spec-1.0.0.Final.jar
62
73
  - lib/jboss-transaction-api_1.1_spec-1.0.0.Final.jar
63
- - lib/hornetq-core-2.2.10.Final.jar
64
- - lib/hornetq-jms-2.2.10.Final.jar
74
+ - lib/hornetq-core-2.2.11.Final.jar
75
+ - lib/hornetq-jms-2.2.11.Final.jar
65
76
  - lib/netty-3.2.6.Final.jar
66
- - lib/gem_hook.rb
67
77
  - lib/org.torquebox.messaging-client.rb
78
+ - lib/gem_hook.rb
68
79
  - lib/torquebox/messaging.rb
69
- - lib/torquebox/messaging/backgroundable.rb
70
- - lib/torquebox/messaging/backgroundable_processor.rb
71
- - lib/torquebox/messaging/connection.rb
72
- - lib/torquebox/messaging/connection_factory.rb
73
80
  - lib/torquebox/messaging/const_missing.rb
74
- - lib/torquebox/messaging/core.rb
75
- - lib/torquebox/messaging/destination.rb
76
- - lib/torquebox/messaging/future.rb
77
- - lib/torquebox/messaging/future_responder.rb
78
- - lib/torquebox/messaging/future_status.rb
79
- - lib/torquebox/messaging/json_message.rb
80
- - lib/torquebox/messaging/marshal_base64_message.rb
81
- - lib/torquebox/messaging/marshal_message.rb
81
+ - lib/torquebox/messaging/session.rb
82
+ - lib/torquebox/messaging/queue.rb
82
83
  - lib/torquebox/messaging/message.rb
84
+ - lib/torquebox/messaging/destination.rb
85
+ - lib/torquebox/messaging/backgroundable.rb
83
86
  - lib/torquebox/messaging/message_processor.rb
84
- - lib/torquebox/messaging/processor_wrapper.rb
85
- - lib/torquebox/messaging/queue.rb
86
- - lib/torquebox/messaging/session.rb
87
- - lib/torquebox/messaging/task.rb
88
87
  - lib/torquebox/messaging/text_message.rb
88
+ - lib/torquebox/messaging/connection.rb
89
+ - lib/torquebox/messaging/task.rb
90
+ - lib/torquebox/messaging/json_message.rb
91
+ - lib/torquebox/messaging/xa_session.rb
92
+ - lib/torquebox/messaging/processor_wrapper.rb
93
+ - lib/torquebox/messaging/future_status.rb
94
+ - lib/torquebox/messaging/backgroundable_processor.rb
95
+ - lib/torquebox/messaging/marshal_message.rb
96
+ - lib/torquebox/messaging/future_responder.rb
97
+ - lib/torquebox/messaging/clojure_message.rb
98
+ - lib/torquebox/messaging/datamapper_marshaling.rb
99
+ - lib/torquebox/messaging/xa_connection_factory.rb
100
+ - lib/torquebox/messaging/connection_factory.rb
101
+ - lib/torquebox/messaging/marshal_base64_message.rb
102
+ - lib/torquebox/messaging/core.rb
89
103
  - lib/torquebox/messaging/topic.rb
90
104
  - lib/torquebox/messaging/xa_connection.rb
91
- - lib/torquebox/messaging/xa_connection_factory.rb
92
- - lib/torquebox/messaging/xa_session.rb
105
+ - lib/torquebox/messaging/future.rb
93
106
  - lib/torquebox/messaging/ext/javax_jms_queue_browser.rb
107
+ - spec/message_spec.rb
94
108
  - spec/backgroundable_spec.rb
95
109
  - spec/destination_spec.rb
96
- - spec/future_responder_spec.rb
97
110
  - spec/future_spec.rb
111
+ - spec/task_spec.rb
98
112
  - spec/json_message_spec.rb
113
+ - spec/future_responder_spec.rb
114
+ - spec/datamapper_marshaling_spec.rb
99
115
  - spec/message_processor_spec.rb
100
- - spec/message_spec.rb
101
- - spec/task_spec.rb
102
116
  homepage: http://www.torquebox.org/torquebox-gems-parent/torquebox-messaging/
103
117
  licenses:
104
118
  - lgpl
@@ -122,16 +136,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
136
  requirements: []
123
137
 
124
138
  rubyforge_project:
125
- rubygems_version: 1.8.9
139
+ rubygems_version: 1.8.15
126
140
  signing_key:
127
141
  specification_version: 3
128
142
  summary: TorqueBox Messaging Client
129
143
  test_files:
144
+ - spec/message_spec.rb
130
145
  - spec/backgroundable_spec.rb
131
146
  - spec/destination_spec.rb
132
- - spec/future_responder_spec.rb
133
147
  - spec/future_spec.rb
148
+ - spec/task_spec.rb
134
149
  - spec/json_message_spec.rb
150
+ - spec/future_responder_spec.rb
151
+ - spec/datamapper_marshaling_spec.rb
135
152
  - spec/message_processor_spec.rb
136
- - spec/message_spec.rb
137
- - spec/task_spec.rb