c y > < g r o u p i d > i o . v e r t x < / g r o u p i d > < a r t i f a c t i d > c o r e < / a r t i f a c t i d > < v e r s i o n > 3 . 2 . 1 < / v e r s i o n > < / d e p e n d e n c y >
v e r t x . c o r e . A b s t r a c t V e r t i c l e ; p u b l i c c l a s s S e r v e r e x t e n d s A b s t r a c t V e r t i c l e { p u b l i c v o i d s t a r t ( ) { v e r t x . c r e a t e H t t p S e r v e r ( ) . r e q u e s t H a n d l e r ( r e q > { r e q . r e s p o n s e ( ) . p u t H e a d e r ( " c o n t e n t t y p e " , " t e x t / p l a i n " ) . e n d ( " H e l l o f r o m V e r t . x ! " ) ; } ) . l i s t e n ( 8 0 8 0 ) ; } }
y ( " S E L E C T * f r o m E M P " , r e s > { i f ( r e s . s u c c e e d e d ( ) ) { / / G e t t h e r e s u l t s e t R e s u l t S e t r e s u l t S e t = r e s . r e s u l t ( ) ; } e l s e { / / F a i l e d ! } } ) ;
e a t e _ h t t p _ s e r v e r ( ) . r e q u e s t _ h a n d l e r ( ) { | r e q | r e q . r e s p o n s e ( ) . p u t _ h e a d e r ( " c o n t e n t t y p e " , " t e x t / p l a i n " ) . e n d ( " H e l l o f r o m V e r t . x ! " ) } . l i s t e n ( 8 0 8 0 )
b = v e r t x . e v e n t B u s ( ) ; e b . c o n s u m e r ( " n e w s . u k . s p o r t " , m e s s a g e > { p r i n t l n ( " I h a v e r e c e i v e d a m e s s a g e : " + m e s s a g e . b o d y ( ) ) ; } ) ;
e ( " / e v e n t b u s / * " ) . h a n d l e r ( S o c k J S H a n d l e r . c r e a t e ( v e r t x ) . b r i d g e ( o p t i o n s ) ) ; v e r t x . c r e a t e H t t p S e r v e r ( ) . r e q u e s t H a n d l e r ( a p p : : a c c e p t ) . l i s t e n ( 8 0 8 0 , r e s > { / / p u b l i s h a n e w m e s s a g e e v e r y 1 0 s e c v e r t x . s e t P e r i o d i c ( 1 0 0 0 0 L , t > { v e r t x . e v e n t B u s ( ) . p u b l i s h ( " t i m e " , n e w J s o n O b j e c t ( ) . p u t ( " u n i x t i m e " , S y s t e m . c u r r e n t T i m e M i l l i s ( ) ) ) ; } ) ; S y s t e m . o u t . p r i n t l n ( " S e r v e r r e a d y ! " ) ; } ) ;
= 0 ; i < s o c k e t s . l e n g t h ; i + + ) { v e r t x . c r e a t e H t t p C l i e n t ( ) . w e b s o c k e t ( 8 0 8 0 , " l o c a l h o s t " , " / e v e n t b u s / w e b s o c k e t " , w s > { w s . f r a m e H a n d l e r ( f r a m e > p r i n t l n ( f r a m e . b i n a r y D a t a ( ) ) ) ; / / s u b s c r i b e t o t h e " t i m e " a d d r e s s w s . w r i t e F r a m e ( W e b S o c k e t F r a m e . t e x t F r a m e ( S U B S C R I B E , t r u e ) ) ; } ) ; }