active_message 0.0.2B
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/active_message.iml +41 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +85 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +79 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/active_message.gemspec +26 -0
- data/bin/active_message_worker +24 -0
- data/lib/active_message.rb +47 -0
- data/lib/active_message/broker.rb +52 -0
- data/lib/active_message/configuration.rb +63 -0
- data/lib/active_message/consumer.rb +34 -0
- data/lib/active_message/logger.rb +58 -0
- data/lib/active_message/version.rb +3 -0
- data/lib/active_message/worker.rb +57 -0
- metadata +137 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 40f5be9eba5374a2d38c652e4b405d0189178b14
|
|
4
|
+
data.tar.gz: e1f6b329ec7e4978fe7450c285fe3c9979a6aa37
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 1d97ee8a2fc834680ab139455c64898242fd37312f767d38647ef1d50667babe0770f7d02811fc66d4f0145c56b7ccb620b366db14238dae62f82065878b2297
|
|
7
|
+
data.tar.gz: 160c746f4b7a350e1574634e0caecdd1eb2381c0de874f5dde39e12b9b986eb609c34ed41372c933f9f7732b22a70d187c753b7b5433830dc455a1abaef7d012
|
data/.gitignore
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
data/.idea/.rakeTasks
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
|
3
|
+
You are allowed to:
|
|
4
|
+
1. Remove rake task
|
|
5
|
+
2. Add existing rake tasks
|
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build active_message-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install active_message-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push active_message-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="FacetManager">
|
|
4
|
+
<facet type="gem" name="Ruby Gem">
|
|
5
|
+
<configuration>
|
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
|
9
|
+
</configuration>
|
|
10
|
+
</facet>
|
|
11
|
+
</component>
|
|
12
|
+
<component name="NewModuleRootManager">
|
|
13
|
+
<content url="file://$MODULE_DIR$" />
|
|
14
|
+
<orderEntry type="jdk" jdkName="RVM: ruby-2.1.1 [aquasol_client]" jdkType="RUBY_SDK" />
|
|
15
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
16
|
+
<orderEntry type="module-library">
|
|
17
|
+
<library name="active_message (v0.0.1, /Users/dustin/Projects/Personal/active_message) [path][gem]">
|
|
18
|
+
<CLASSES>
|
|
19
|
+
<root url="file://$MODULE_DIR$/bin" />
|
|
20
|
+
<root url="file://$MODULE_DIR$/lib" />
|
|
21
|
+
<root url="file://$MODULE_DIR$/.idea" />
|
|
22
|
+
<root url="file://$MODULE_DIR$/config" />
|
|
23
|
+
</CLASSES>
|
|
24
|
+
<SOURCES>
|
|
25
|
+
<root url="file://$MODULE_DIR$/bin" />
|
|
26
|
+
<root url="file://$MODULE_DIR$/lib" />
|
|
27
|
+
<root url="file://$MODULE_DIR$/.idea" />
|
|
28
|
+
<root url="file://$MODULE_DIR$/config" />
|
|
29
|
+
</SOURCES>
|
|
30
|
+
</library>
|
|
31
|
+
</orderEntry>
|
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="amq-protocol (v1.9.2, RVM: ruby-2.1.1 [aquasol_client]) [gem]" level="application" />
|
|
33
|
+
<orderEntry type="library" scope="PROVIDED" name="bunny (v1.2.1, RVM: ruby-2.1.1 [aquasol_client]) [gem]" level="application" />
|
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="daemons (v1.1.9, RVM: ruby-2.1.1 [aquasol_client]) [gem]" level="application" />
|
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="little-plugger (v1.1.3, RVM: ruby-2.1.1 [aquasol_client]) [gem]" level="application" />
|
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="logging (v1.8.2, RVM: ruby-2.1.1 [aquasol_client]) [gem]" level="application" />
|
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.10.0, RVM: ruby-2.1.1 [aquasol_client]) [gem]" level="application" />
|
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.3.1, RVM: ruby-2.1.1 [aquasol_client]) [gem]" level="application" />
|
|
39
|
+
</component>
|
|
40
|
+
</module>
|
|
41
|
+
|
data/.idea/encodings.xml
ADDED
data/.idea/misc.xml
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="CompilerConfiguration">
|
|
4
|
+
<option name="DEFAULT_COMPILER" />
|
|
5
|
+
<resourceExtensions />
|
|
6
|
+
<wildcardResourcePatterns>
|
|
7
|
+
<entry name="!?*.java" />
|
|
8
|
+
<entry name="!?*.form" />
|
|
9
|
+
<entry name="!?*.class" />
|
|
10
|
+
<entry name="!?*.groovy" />
|
|
11
|
+
<entry name="!?*.scala" />
|
|
12
|
+
<entry name="!?*.flex" />
|
|
13
|
+
<entry name="!?*.kt" />
|
|
14
|
+
<entry name="!?*.clj" />
|
|
15
|
+
</wildcardResourcePatterns>
|
|
16
|
+
<annotationProcessing>
|
|
17
|
+
<profile default="true" name="Default" enabled="false">
|
|
18
|
+
<processorPath useClasspath="true" />
|
|
19
|
+
</profile>
|
|
20
|
+
</annotationProcessing>
|
|
21
|
+
</component>
|
|
22
|
+
<component name="CopyrightManager" default="">
|
|
23
|
+
<module2copyright />
|
|
24
|
+
</component>
|
|
25
|
+
<component name="DebuggerManager">
|
|
26
|
+
<breakpoint_any>
|
|
27
|
+
<breakpoint>
|
|
28
|
+
<option name="NOTIFY_CAUGHT" value="true" />
|
|
29
|
+
<option name="NOTIFY_UNCAUGHT" value="true" />
|
|
30
|
+
<option name="ENABLED" value="false" />
|
|
31
|
+
<option name="LOG_ENABLED" value="false" />
|
|
32
|
+
<option name="LOG_EXPRESSION_ENABLED" value="false" />
|
|
33
|
+
<option name="REMOVE_AFTER_HIT" value="false" />
|
|
34
|
+
<option name="SUSPEND_POLICY" value="SuspendAll" />
|
|
35
|
+
<option name="SUSPEND" value="true" />
|
|
36
|
+
<option name="COUNT_FILTER_ENABLED" value="false" />
|
|
37
|
+
<option name="COUNT_FILTER" value="0" />
|
|
38
|
+
<option name="CONDITION_ENABLED" value="true" />
|
|
39
|
+
<option name="CLASS_FILTERS_ENABLED" value="false" />
|
|
40
|
+
<option name="INSTANCE_FILTERS_ENABLED" value="false" />
|
|
41
|
+
<option name="CONDITION" value="" />
|
|
42
|
+
<option name="LOG_MESSAGE" value="" />
|
|
43
|
+
</breakpoint>
|
|
44
|
+
<breakpoint>
|
|
45
|
+
<option name="NOTIFY_CAUGHT" value="true" />
|
|
46
|
+
<option name="NOTIFY_UNCAUGHT" value="true" />
|
|
47
|
+
<option name="ENABLED" value="false" />
|
|
48
|
+
<option name="LOG_ENABLED" value="false" />
|
|
49
|
+
<option name="LOG_EXPRESSION_ENABLED" value="false" />
|
|
50
|
+
<option name="REMOVE_AFTER_HIT" value="false" />
|
|
51
|
+
<option name="SUSPEND_POLICY" value="SuspendAll" />
|
|
52
|
+
<option name="SUSPEND" value="true" />
|
|
53
|
+
<option name="COUNT_FILTER_ENABLED" value="false" />
|
|
54
|
+
<option name="COUNT_FILTER" value="0" />
|
|
55
|
+
<option name="CONDITION_ENABLED" value="true" />
|
|
56
|
+
<option name="CLASS_FILTERS_ENABLED" value="false" />
|
|
57
|
+
<option name="INSTANCE_FILTERS_ENABLED" value="false" />
|
|
58
|
+
<option name="CONDITION" value="" />
|
|
59
|
+
<option name="LOG_MESSAGE" value="" />
|
|
60
|
+
</breakpoint>
|
|
61
|
+
</breakpoint_any>
|
|
62
|
+
<breakpoint_rules />
|
|
63
|
+
<ui_properties />
|
|
64
|
+
</component>
|
|
65
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.1.1 [aquasol]" project-jdk-type="RUBY_SDK" />
|
|
66
|
+
<component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false" SSL_PROTOCOLS="sslv3">
|
|
67
|
+
<option name="USER" value="" />
|
|
68
|
+
<option name="PASSWORD" value="" />
|
|
69
|
+
<option name="mySSHConnectionTimeout" value="30000" />
|
|
70
|
+
<option name="mySSHReadTimeout" value="30000" />
|
|
71
|
+
<option name="LAST_MERGED_REVISION" />
|
|
72
|
+
<option name="MERGE_DRY_RUN" value="false" />
|
|
73
|
+
<option name="MERGE_DIFF_USE_ANCESTRY" value="true" />
|
|
74
|
+
<option name="UPDATE_LOCK_ON_DEMAND" value="false" />
|
|
75
|
+
<option name="IGNORE_SPACES_IN_MERGE" value="false" />
|
|
76
|
+
<option name="CHECK_NESTED_FOR_QUICK_MERGE" value="false" />
|
|
77
|
+
<option name="IGNORE_SPACES_IN_ANNOTATE" value="true" />
|
|
78
|
+
<option name="SHOW_MERGE_SOURCES_IN_ANNOTATE" value="true" />
|
|
79
|
+
<option name="FORCE_UPDATE" value="false" />
|
|
80
|
+
<option name="IGNORE_EXTERNALS" value="false" />
|
|
81
|
+
<configuration useDefault="true">$USER_HOME$/.subversion</configuration>
|
|
82
|
+
<myIsUseDefaultProxy>false</myIsUseDefaultProxy>
|
|
83
|
+
</component>
|
|
84
|
+
</project>
|
|
85
|
+
|
data/.idea/modules.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/active_message.iml" filepath="$PROJECT_DIR$/.idea/active_message.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
9
|
+
|
data/.idea/vcs.xml
ADDED
data/.idea/workspace.xml
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<option name="TRACKING_ENABLED" value="true" />
|
|
5
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
6
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
7
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
8
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
9
|
+
</component>
|
|
10
|
+
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
|
|
11
|
+
<component name="CreatePatchCommitExecutor">
|
|
12
|
+
<option name="PATCH_PATH" value="" />
|
|
13
|
+
</component>
|
|
14
|
+
<component name="DaemonCodeAnalyzer">
|
|
15
|
+
<disable_hints />
|
|
16
|
+
</component>
|
|
17
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
|
18
|
+
<OptionsSetting value="true" id="Add" />
|
|
19
|
+
<OptionsSetting value="true" id="Remove" />
|
|
20
|
+
<OptionsSetting value="true" id="Checkout" />
|
|
21
|
+
<OptionsSetting value="true" id="Update" />
|
|
22
|
+
<OptionsSetting value="true" id="Status" />
|
|
23
|
+
<OptionsSetting value="true" id="Edit" />
|
|
24
|
+
<ConfirmationsSetting value="0" id="Add" />
|
|
25
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
|
26
|
+
</component>
|
|
27
|
+
<component name="ProjectReloadState">
|
|
28
|
+
<option name="STATE" value="0" />
|
|
29
|
+
</component>
|
|
30
|
+
<component name="PropertiesComponent">
|
|
31
|
+
<property name="GoToFile.includeJavaFiles" value="false" />
|
|
32
|
+
<property name="GoToClass.toSaveIncludeLibraries" value="false" />
|
|
33
|
+
<property name="options.splitter.main.proportions" value="0.3" />
|
|
34
|
+
<property name="MemberChooser.sorted" value="false" />
|
|
35
|
+
<property name="options.lastSelected" value="org.jetbrains.plugins.ruby.settings.RubyActiveModuleSdkConfigurable" />
|
|
36
|
+
<property name="last_opened_file_path" value="$PROJECT_DIR$/../SLIMS-HI" />
|
|
37
|
+
<property name="MemberChooser.showClasses" value="true" />
|
|
38
|
+
<property name="GoToClass.includeLibraries" value="false" />
|
|
39
|
+
<property name="MemberChooser.copyJavadoc" value="false" />
|
|
40
|
+
<property name="options.splitter.details.proportions" value="0.2" />
|
|
41
|
+
<property name="options.searchVisible" value="true" />
|
|
42
|
+
</component>
|
|
43
|
+
<component name="RunManager">
|
|
44
|
+
<list size="0" />
|
|
45
|
+
<configuration name="<template>" type="JUnit" default="true" selected="false">
|
|
46
|
+
<option name="MAIN_CLASS_NAME" />
|
|
47
|
+
<option name="VM_PARAMETERS" value="-ea" />
|
|
48
|
+
<option name="PARAMETERS" />
|
|
49
|
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
|
50
|
+
</configuration>
|
|
51
|
+
<configuration name="<template>" type="TestNG" default="true" selected="false">
|
|
52
|
+
<option name="MAIN_CLASS_NAME" />
|
|
53
|
+
<option name="VM_PARAMETERS" value="-ea" />
|
|
54
|
+
<option name="PARAMETERS" />
|
|
55
|
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
|
56
|
+
</configuration>
|
|
57
|
+
<configuration name="<template>" type="WebApp" default="true" selected="false">
|
|
58
|
+
<Host>localhost</Host>
|
|
59
|
+
<Port>5050</Port>
|
|
60
|
+
</configuration>
|
|
61
|
+
</component>
|
|
62
|
+
<component name="ShelveChangesManager" show_recycled="false" />
|
|
63
|
+
<component name="TaskManager">
|
|
64
|
+
<task active="true" id="Default" summary="Default task" />
|
|
65
|
+
<servers />
|
|
66
|
+
</component>
|
|
67
|
+
<component name="VcsContentAnnotationSettings">
|
|
68
|
+
<option name="myLimit" value="2678400000" />
|
|
69
|
+
</component>
|
|
70
|
+
<component name="VcsManagerConfiguration">
|
|
71
|
+
<option name="myTodoPanelSettings">
|
|
72
|
+
<TodoPanelSettings />
|
|
73
|
+
</option>
|
|
74
|
+
</component>
|
|
75
|
+
<component name="XDebuggerManager">
|
|
76
|
+
<breakpoint-manager />
|
|
77
|
+
</component>
|
|
78
|
+
</project>
|
|
79
|
+
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Dustin Ward
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# ActiveMessage
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'active_message'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install active_message
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
TODO: Write usage instructions here
|
|
22
|
+
|
|
23
|
+
## Contributing
|
|
24
|
+
|
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/active_message/fork )
|
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'active_message/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "active_message"
|
|
8
|
+
spec.version = ActiveMessage::VERSION
|
|
9
|
+
spec.authors = ["Dustin Ward"]
|
|
10
|
+
spec.email = ["dustin.n.ward@gmail.com"]
|
|
11
|
+
spec.summary = "Active Messaging For AMQP"
|
|
12
|
+
spec.description = "Active Messaging For AMQP"
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = ["active_message_worker"]
|
|
18
|
+
spec.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
spec.add_dependency "logging"
|
|
21
|
+
spec.add_dependency "bunny"
|
|
22
|
+
spec.add_dependency "daemons"
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
25
|
+
spec.add_development_dependency "rake"
|
|
26
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "rubygems"
|
|
4
|
+
require "active_message"
|
|
5
|
+
require "daemons"
|
|
6
|
+
|
|
7
|
+
APP_PATH = File.expand_path(File.join('.', 'config/application.rb'))
|
|
8
|
+
CONFIG_PATH = File.expand_path(File.join('.', 'config/active_message.yml'))
|
|
9
|
+
ENV["RAILS_ENV"] ||= "development"
|
|
10
|
+
|
|
11
|
+
Daemons.run_proc('active_message_worker') do
|
|
12
|
+
if File.exist? APP_PATH
|
|
13
|
+
require APP_PATH
|
|
14
|
+
Rails.application.require_environment!
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
if File.exist? CONFIG_PATH
|
|
18
|
+
ActiveMessage::Configuration.load_from_file(CONFIG_PATH)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
ActiveMessage.connect
|
|
22
|
+
worker = ActiveMessage::Worker.new
|
|
23
|
+
worker.run
|
|
24
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require "logging"
|
|
2
|
+
require "bunny"
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
5
|
+
module ActiveMessage
|
|
6
|
+
autoload :Consumer, 'active_message/consumer'
|
|
7
|
+
autoload :Worker, 'active_message/worker'
|
|
8
|
+
autoload :DemoWorker, 'active_message/demo_worker'
|
|
9
|
+
autoload :DemoWorkerB, 'active_message/demo_worker_b'
|
|
10
|
+
autoload :Broker, 'active_message/broker'
|
|
11
|
+
autoload :Version, 'active_message/version'
|
|
12
|
+
autoload :Logger, 'active_message/logger'
|
|
13
|
+
autoload :Configuration, 'active_message/configuration'
|
|
14
|
+
|
|
15
|
+
def self.register_consumer(klass)
|
|
16
|
+
ActiveMessage::Logger.debug "Registered Consumer: #{klass.name}"
|
|
17
|
+
self.consumers << klass
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.consumers
|
|
21
|
+
@consumers ||= []
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.connect(config = ActiveMessage::Configuration)
|
|
25
|
+
ActiveMessage::Logger.debug "Connecting to AMQP ...."
|
|
26
|
+
@broker = ActiveMessage::Broker.instance
|
|
27
|
+
@broker.connect(config)
|
|
28
|
+
@connected = true
|
|
29
|
+
ActiveMessage::Logger.debug "Connected to AMQP ...."
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.broker
|
|
33
|
+
@broker
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.connected
|
|
37
|
+
@connected
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.publish(*args)
|
|
41
|
+
self.broker.publish(*args)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.version
|
|
45
|
+
ActiveMessage::VERSION
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module ActiveMessage
|
|
2
|
+
class Broker
|
|
3
|
+
include Singleton
|
|
4
|
+
|
|
5
|
+
attr_accessor :configuration
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def connect(config)
|
|
11
|
+
@configuration = config
|
|
12
|
+
@connection = Bunny.new(host: ActiveMessage::Configuration.get(:host), auth_mechanism: "EXTERNAL", tls: ActiveMessage::Configuration.get(:tls), tls_cert: ActiveMessage::Configuration.get(:tls_cert), tls_key: ActiveMessage::Configuration.get(:tls_key), tls_ca_certificates: ActiveMessage::Configuration.get(:tls_ca_certificates))
|
|
13
|
+
@connection.start
|
|
14
|
+
@exchange = @connection.topic(@configuration[:exchange] || "demo", auto_delete: true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def disconnect
|
|
18
|
+
self.connection.close
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def connection
|
|
22
|
+
@connection
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def exchange
|
|
26
|
+
@exchange
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def ack(channel, delivery_tag)
|
|
30
|
+
channel.ack(delivery_tag, false)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def nack(channel, delivery_tag)
|
|
34
|
+
channel.nack(delivery_tag, false, false)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def publish(routing_key, message, properties = {})
|
|
38
|
+
ActiveMessage::Logger.debug "Publishing Message => '#{message.inspect}' to #{routing_key}"
|
|
39
|
+
non_overridable_properties = {
|
|
40
|
+
routing_key: routing_key,
|
|
41
|
+
timestamp: Time.now.to_i,
|
|
42
|
+
content_type: 'application/json'
|
|
43
|
+
}
|
|
44
|
+
properties[:message_id] ||= generate_id
|
|
45
|
+
exchange.publish(message, { persistent: true }.merge(properties).merge(non_overridable_properties))
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def generate_id
|
|
49
|
+
SecureRandom.uuid
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module ActiveMessage
|
|
2
|
+
class UnknownAttributeError < StandardError; end
|
|
3
|
+
|
|
4
|
+
module Configuration
|
|
5
|
+
def self.initialize
|
|
6
|
+
@config = {
|
|
7
|
+
host: 'localhost',
|
|
8
|
+
port: 5672,
|
|
9
|
+
exchange: 'ActiveMessage',
|
|
10
|
+
vhost: '/',
|
|
11
|
+
tls: false,
|
|
12
|
+
tls_cert: nil,
|
|
13
|
+
tls_key: nil,
|
|
14
|
+
tls_ca_certificates: [],
|
|
15
|
+
username: 'dustin',
|
|
16
|
+
password: ''
|
|
17
|
+
}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.get(attr)
|
|
21
|
+
check_attr(attr)
|
|
22
|
+
user_config[attr]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.set(attr, value)
|
|
26
|
+
check_attr(attr)
|
|
27
|
+
user_config[attr] = value
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class << self
|
|
31
|
+
alias_method :[], :get
|
|
32
|
+
alias_method :[]=, :set
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.user_config
|
|
36
|
+
initialize unless @config
|
|
37
|
+
@config
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.check_attr(attr)
|
|
41
|
+
unless user_config.key?(attr)
|
|
42
|
+
raise ActiveMessage::UnknownAttributeError, "#{attr} is not a valid config attribute"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.load_from_file(file)
|
|
47
|
+
YAML.load(File.read(file)).each do |attr, value|
|
|
48
|
+
ActiveMessage::Configuration.send("#{attr}=", value)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.method_missing(method, *args, &block)
|
|
53
|
+
attr = method.to_s.sub(/=$/, '').to_sym
|
|
54
|
+
return super unless user_config.key?(attr)
|
|
55
|
+
|
|
56
|
+
if method =~ /=$/
|
|
57
|
+
set(attr, args.first)
|
|
58
|
+
else
|
|
59
|
+
get(attr)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module ActiveMessage
|
|
2
|
+
module Consumer
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.extend(ClassMethods)
|
|
5
|
+
ActiveMessage.register_consumer(base)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module ClassMethods
|
|
9
|
+
def consume(*routing_keys)
|
|
10
|
+
ActiveMessage::Logger.debug "Consumer is consuming #{routing_keys.join(", ")} ...."
|
|
11
|
+
@routing_keys = self.routing_keys.union(routing_keys)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def queue_name(name)
|
|
15
|
+
@queue_name = name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get_queue_name
|
|
19
|
+
return @queue_name unless @queue_name.nil?
|
|
20
|
+
queue_name = self.name.gsub(/::/, ':')
|
|
21
|
+
queue_name.gsub!(/([^A-Z:])([A-Z])/) { "#{$1}_#{$2}" }
|
|
22
|
+
queue_name.downcase
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def routing_keys
|
|
26
|
+
@routing_keys ||= Set.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def process(delivery_info, properties, payload)
|
|
30
|
+
ActiveMessage::Logger.debug "Please implement this method in your consumer ...."
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module ActiveMessage
|
|
2
|
+
class Logger
|
|
3
|
+
include Singleton
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
setup_colorization
|
|
7
|
+
Logging.appenders.stdout(
|
|
8
|
+
'stdout',
|
|
9
|
+
layout: Logging.layouts.pattern(
|
|
10
|
+
pattern: '[%d] %-5l %c: %m\n',
|
|
11
|
+
color_scheme: 'bright'
|
|
12
|
+
)
|
|
13
|
+
)
|
|
14
|
+
@app_log = Logging.logger['ActiveMessage']
|
|
15
|
+
@app_log.add_appenders 'stdout'
|
|
16
|
+
@app_log.level = :debug
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def log
|
|
20
|
+
@app_log
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.debug(message)
|
|
24
|
+
self.instance.log.debug(message)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.info(message)
|
|
28
|
+
self.instance.log.info(message)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.warn(message)
|
|
32
|
+
self.instance.log.warn(message)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.error(message)
|
|
36
|
+
self.instance.log.error(message)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.fatal(message)
|
|
40
|
+
self.instance.log.fatal(message)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
def setup_colorization
|
|
45
|
+
Logging.color_scheme('bright',
|
|
46
|
+
levels: {
|
|
47
|
+
info: :green,
|
|
48
|
+
warn: :yellow,
|
|
49
|
+
error: :red,
|
|
50
|
+
fatal: [:white, :on_red]
|
|
51
|
+
},
|
|
52
|
+
date: :blue,
|
|
53
|
+
logger: :cyan,
|
|
54
|
+
message: :magenta
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module ActiveMessage
|
|
2
|
+
class Worker
|
|
3
|
+
def initializer
|
|
4
|
+
ActiveMessage::Logger.debug "Initialized ActiveMessage Worker ...."
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def run
|
|
8
|
+
ActiveMessage::Logger.debug "ActiveMessage Worker Started ...."
|
|
9
|
+
setup_bindings
|
|
10
|
+
threads.each(&:join)
|
|
11
|
+
ActiveMessage::Logger.debug "ActiveMessage Worker Stopped ...."
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def threads
|
|
15
|
+
@threads ||= []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def handle_message(consumer, channel, delivery_info, properties, payload)
|
|
21
|
+
begin
|
|
22
|
+
ActiveMessage::Logger.debug ".... Received New Message ...."
|
|
23
|
+
ActiveMessage::Logger.debug "#{consumer.name}"
|
|
24
|
+
ActiveMessage::Logger.debug "#{properties.inspect}"
|
|
25
|
+
ActiveMessage::Logger.debug "#{payload.inspect}"
|
|
26
|
+
channel.ack(delivery_info.delivery_tag, false)
|
|
27
|
+
consumer.new.process(delivery_info, properties, payload)
|
|
28
|
+
rescue StandardError => ex
|
|
29
|
+
#handle_error(properties.message_id, consumer, ex)
|
|
30
|
+
channel.nack(delivery_info.delivery_tag, false, false)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def setup_bindings
|
|
35
|
+
if ActiveMessage.consumers.size <= 0
|
|
36
|
+
ActiveMessage::Logger.fatal "No ActiveRecord Consumers Loaded ...."
|
|
37
|
+
exit
|
|
38
|
+
end
|
|
39
|
+
ActiveMessage.consumers.each do |consumer|
|
|
40
|
+
thread = Thread.new do
|
|
41
|
+
channel = ActiveMessage.broker.connection.create_channel
|
|
42
|
+
Thread.current.thread_variable_set(:consumer, consumer)
|
|
43
|
+
Thread.current.thread_variable_set(:channel, channel)
|
|
44
|
+
channel = Thread.current.thread_variable_get(:channel)
|
|
45
|
+
consumer = Thread.current.thread_variable_get(:consumer)
|
|
46
|
+
channel.queue(consumer.get_queue_name, durable: true).bind(ActiveMessage.broker.exchange, routing_key: consumer.routing_keys.first).subscribe(ack: true) do |delivery_info, properties, payload|
|
|
47
|
+
handle_message(consumer, channel, delivery_info, properties, payload)
|
|
48
|
+
end
|
|
49
|
+
loop do
|
|
50
|
+
sleep 5.0
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
threads.push(thread)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: active_message
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2B
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Dustin Ward
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: logging
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bunny
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: daemons
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: bundler
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.6'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.6'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rake
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: Active Messaging For AMQP
|
|
84
|
+
email:
|
|
85
|
+
- dustin.n.ward@gmail.com
|
|
86
|
+
executables:
|
|
87
|
+
- active_message_worker
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".idea/.rakeTasks"
|
|
93
|
+
- ".idea/active_message.iml"
|
|
94
|
+
- ".idea/encodings.xml"
|
|
95
|
+
- ".idea/misc.xml"
|
|
96
|
+
- ".idea/modules.xml"
|
|
97
|
+
- ".idea/scopes/scope_settings.xml"
|
|
98
|
+
- ".idea/vcs.xml"
|
|
99
|
+
- ".idea/workspace.xml"
|
|
100
|
+
- Gemfile
|
|
101
|
+
- LICENSE.txt
|
|
102
|
+
- README.md
|
|
103
|
+
- Rakefile
|
|
104
|
+
- active_message.gemspec
|
|
105
|
+
- bin/active_message_worker
|
|
106
|
+
- lib/active_message.rb
|
|
107
|
+
- lib/active_message/broker.rb
|
|
108
|
+
- lib/active_message/configuration.rb
|
|
109
|
+
- lib/active_message/consumer.rb
|
|
110
|
+
- lib/active_message/logger.rb
|
|
111
|
+
- lib/active_message/version.rb
|
|
112
|
+
- lib/active_message/worker.rb
|
|
113
|
+
homepage: ''
|
|
114
|
+
licenses:
|
|
115
|
+
- MIT
|
|
116
|
+
metadata: {}
|
|
117
|
+
post_install_message:
|
|
118
|
+
rdoc_options: []
|
|
119
|
+
require_paths:
|
|
120
|
+
- lib
|
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - ">"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: 1.3.1
|
|
131
|
+
requirements: []
|
|
132
|
+
rubyforge_project:
|
|
133
|
+
rubygems_version: 2.2.2
|
|
134
|
+
signing_key:
|
|
135
|
+
specification_version: 4
|
|
136
|
+
summary: Active Messaging For AMQP
|
|
137
|
+
test_files: []
|