@@ -6,7 +6,7 @@ import { Attributes, Validator } from 'validator-x';
6
6
import { ApplicationContext } from './context' ;
7
7
import { HealthController } from './controllers/HealthController' ;
8
8
import { User } from './models/User' ;
9
- import { ActiveMQSender , ActiveMQSubscriber , Config } from './services/activemq' ;
9
+ import { ActiveMQSubscriber , ActiveMQWriter , Config } from './services/activemq' ;
10
10
import { ActiveMQChecker } from './services/activemq' ;
11
11
12
12
const retries = [ 5000 , 10000 , 20000 ] ;
@@ -36,16 +36,16 @@ const user: Attributes = {
36
36
37
37
export function createContext ( db : Db , client : Client , config : Config ) : ApplicationContext {
38
38
const atmqChecker = new ActiveMQChecker ( config ) ;
39
- const healthController = new HealthController ( [ atmqChecker ] ) ;
40
- const writer = new MongoInserter ( db . collection ( 'users' ) , 'id' ) ;
41
- const retryWriter = new RetryWriter ( writer . write , retries , writeUser , log ) ;
39
+ const health = new HealthController ( [ atmqChecker ] ) ;
40
+ const dbwriter = new MongoInserter ( db . collection ( 'users' ) , 'id' ) ;
41
+ const retryWriter = new RetryWriter ( dbwriter . write , retries , writeUser , log ) ;
42
42
const errorHandler = new ErrorHandler ( log ) ;
43
43
const validator = new Validator < User > ( user , true ) ;
44
- const consumer = new ActiveMQSubscriber < User > ( client , config . destinationName , config . subscriptionName , 'client-individual' , true , undefined , undefined , log , log ) ;
45
- const producer = new ActiveMQSender < User > ( client , config . destinationName , config . subscriptionName ) ;
46
- const retryService = new RetryService < User , boolean > ( producer . produce , log , log ) ;
44
+ const subscriber = new ActiveMQSubscriber < User > ( client , config . destinationName , config . subscriptionName , 'client-individual' , true , undefined , undefined , log , log ) ;
45
+ const writer = new ActiveMQWriter < User > ( client , config . destinationName , config . subscriptionName ) ;
46
+ const retryService = new RetryService < User , boolean > ( writer . write , log , log ) ;
47
47
const handler = new Handler < User , boolean > ( retryWriter . write , validator . validate , retries , errorHandler . error , log , log , retryService . retry , 3 , 'retry' ) ;
48
- const ctx : ApplicationContext = { handle : handler . handle , read : consumer . consume , health : healthController } ;
48
+ const ctx : ApplicationContext = { handle : handler . handle , read : subscriber . subscribe , health } ;
49
49
return ctx ;
50
50
}
51
51
0 commit comments