Skip to content

Commit

Permalink
initial integration of kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaslin committed Mar 24, 2015
1 parent eb493ae commit 8d47d19
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 34 deletions.
22 changes: 17 additions & 5 deletions echo-stomp/echo-stomp.gradle → echo-kafka/echo-kafka.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
/*
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply from: "$rootDir/gradle/groovy-module.gradle"

ext {
kafkaVersion = '0.8.1.1'
scalaVersion = '2.10'
}

dependencies {
compile project(':echo-model')
compile 'org.springframework.boot:spring-boot-starter-websocket:1.1.7.RELEASE'
compile 'org.springframework:spring-messaging:4.0.7.RELEASE'
compile spinnaker.dependency('bootWeb')
compile commonDependencies.kork
compile commonDependencies.jacksonDatabind
testCompile commonDependencies.spockSpring
testCompile commonDependencies.springTest
testCompile commonDependencies.objenesis

compile("org.apache.kafka:kafka_$scalaVersion:$kafkaVersion") {
exclude module: 'jms'
exclude module: 'jmxtools'
exclude module: 'jmxri'
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config

import org.springframework.context.annotation.Configuration

/**
* Enables Cassandra for this project
*/
@Configuration
@SuppressWarnings('GStringExpressionWithinString')
class KafkaProducerConfig {

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,42 @@

package com.netflix.spinnaker.echo.events

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.echo.model.Event
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.messaging.simp.SimpMessagingTemplate
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Component

/**
* Event listener for stomp
* Event listener for echo events
*/
@Component
class StompEventListener implements EchoEventListener {
class KafkaEventListener implements EchoEventListener {

@Autowired
SimpMessagingTemplate template
ObjectMapper mapper = new ObjectMapper()

@Value('${kafka.prefix}')
String prefix

@Value('${kafka.hostname}')
String hostname

@Value('${kafka.app}')
String app

@Value('${kafka.rowid}')
String rowid

@Override
void processEvent(Event event) {

if (event.details.application) {
template.convertAndSend(
'/topic/application/' + event.details.application,
event
)
}

template.convertAndSend(
'/topic/source/' + event.details.source,
event
)

template.convertAndSend(
'/topic/type/' + event.details.type,
event
)

template.convertAndSend(
'/topic/events',
event
)
Map eventAsMap = mapper.convertValue(event, Map)

eventAsMap."${prefix}_ts" = new Date().time
eventAsMap."${prefix}_app" = app
eventAsMap."${prefix}_hostname" = hostname
eventAsMap."${prefix}_rowid" = rowid

println eventAsMap

}

Expand Down
2 changes: 1 addition & 1 deletion echo-web/echo-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
compile project(':echo-model')
compile project(':echo-cassandra')
compile project(':echo-elasticsearch')
// compile project(':echo-stomp')
compile project(':echo-kafka')
compile spinnaker.dependency('bootActuator')
compile spinnaker.dependency('bootWeb')
compile commonDependencies.springWeb
Expand Down
6 changes: 6 additions & 0 deletions echo-web/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ search:
index: 'event_history'
# server:
# port: 8120

kafka:
prefix: 'suro'
hostname: 'echo.prod.netflix.com'
app: 'spinnaker'
rowid: 'events'
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

include 'echo-core', 'echo-model', 'echo-cassandra', 'echo-web', 'echo-elasticsearch', 'echo-stomp'
include 'echo-core', 'echo-model', 'echo-cassandra', 'echo-web', 'echo-elasticsearch', 'echo-kafka'

rootProject.name = 'echo'

Expand Down

0 comments on commit 8d47d19

Please sign in to comment.