Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
Store-Producer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mahesh Rohra
Store-Producer
Commits
cc96837e
Commit
cc96837e
authored
May 07, 2020
by
Mahesh Rohra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feign client
parent
2a2fa55b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
48 deletions
+8
-48
build.gradle
build.gradle
+1
-2
ConfigProps.java
src/main/java/com/safeway/epe/Config/ConfigProps.java
+0
-21
ProducerServiceProxy.java
...ain/java/com/safeway/epe/Config/ProducerServiceProxy.java
+5
-7
TransactionRecorder.java
...main/java/com/safeway/epe/domain/TransactionRecorder.java
+0
-6
ProducerService.java
src/main/java/com/safeway/epe/service/ProducerService.java
+2
-12
No files found.
build.gradle
View file @
cc96837e
...
...
@@ -6,7 +6,7 @@ plugins {
group
=
'com.safeway.epe'
version
=
'0.0.1-SNAPSHOT'
sourceCompatibility
=
'1
.8
'
sourceCompatibility
=
'1
1
'
configurations
{
developmentOnly
...
...
@@ -27,7 +27,6 @@ repositories {
}
dependencies
{
implementation
'org.springframework.cloud:spring-cloud-starter-config'
implementation
'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation
'org.springframework.boot:spring-boot-starter-data-jpa'
implementation
'org.springframework.boot:spring-boot-starter-web'
...
...
src/main/java/com/safeway/epe/Config/ConfigProps.java
View file @
cc96837e
...
...
@@ -3,13 +3,7 @@ package com.safeway.epe.Config;
import
lombok.Data
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.boot.web.client.RootUriTemplateHandler
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.util.UriTemplateHandler
;
@Data
@Configuration
...
...
@@ -17,22 +11,7 @@ import org.springframework.web.util.UriTemplateHandler;
public
class
ConfigProps
{
private
String
offerTransactionRecordTopic
;
@Value
(
"${schema.api.baseurl}"
)
private
String
schemaBaseUrl
;
private
static
final
String
USER_AGENT
=
"Producer"
;
private
static
final
String
APPLICATION_KAFKA_JSON_VALUE
=
"application/vnd.kafka.json.v2+json"
;
private
static
final
String
ACCEPT_APPLICATION_KAFKA_JSON_VALUE
=
"application/vnd.kafka.v2+json"
;
@Bean
RestTemplate
restTemplate
(
RestTemplateBuilder
builder
)
{
UriTemplateHandler
uriTemplateHandler
=
new
RootUriTemplateHandler
(
schemaBaseUrl
);
return
builder
.
uriTemplateHandler
(
uriTemplateHandler
)
.
defaultHeader
(
HttpHeaders
.
USER_AGENT
,
USER_AGENT
)
.
defaultHeader
(
HttpHeaders
.
CONTENT_TYPE
,
APPLICATION_KAFKA_JSON_VALUE
)
.
defaultHeader
(
HttpHeaders
.
ACCEPT
,
ACCEPT_APPLICATION_KAFKA_JSON_VALUE
)
.
build
();
}
}
src/main/java/com/safeway/epe/Config/ProducerServiceProxy.java
View file @
cc96837e
...
...
@@ -8,14 +8,12 @@ import org.springframework.cloud.openfeign.FeignClient;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
@FeignClient
(
name
=
"service"
,
url
=
"
localhost:8082
"
)
//@Headers({"User-Agent:Producer","Content-Type:application/vnd.kafka.json.v2+json
","Accept:application/vnd.kafka.v2+json"})
@FeignClient
(
name
=
"service"
,
url
=
"
${schema.api.baseurl}
"
)
@Headers
({
"User-Agent:Producer
"
,
"Accept:application/vnd.kafka.v2+json"
})
public
interface
ProducerServiceProxy
{
@
RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"topics/{topic}"
,
consumes
=
"application/vnd.kafka.json.v2+json"
)
@
PostMapping
(
value
=
"topics/{topic}"
,
consumes
=
"application/vnd.kafka.json.v2+json"
)
ResponseEntity
<
ConsumerPayload
>
produceTransactionService
(
@PathVariable
(
"topic"
)
String
topic
,
@RequestBody
TransactionPayload
transactionPayload
,
@RequestHeader
(
"Accept"
)
String
accept
,
//@RequestHeader("Content-Type") String contentType,
@RequestHeader
(
"User-Agent"
)
String
useAgent
);
@RequestBody
TransactionPayload
transactionPayload
);
}
src/main/java/com/safeway/epe/domain/TransactionRecorder.java
View file @
cc96837e
...
...
@@ -33,16 +33,10 @@ public class TransactionRecorder
@Column
(
name
=
"uuid"
)
@JsonProperty
(
"uuid"
)
UUID
uuid
;
// @Type(type = "jsonb")
// @JsonProperty("offertransactionresponse")
@Column
(
name
=
"offertransactionresponse"
)
String
offerTransactionResponse
;
// @Type(type="jsonb")
// @JsonProperty("offers")
@Column
(
name
=
"offers"
)
String
offers
;
@Column
(
name
=
"isprocessed"
)
boolean
isProcessed
;
}
src/main/java/com/safeway/epe/service/ProducerService.java
View file @
cc96837e
...
...
@@ -10,9 +10,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.List
;
import
java.util.function.Consumer
;
@Component
public
class
ProducerService
...
...
@@ -22,21 +20,13 @@ public class ProducerService
@Autowired
private
TransactionService
transactionService
;
@Autowired
private
RestTemplate
restTemplate
;
@Autowired
private
ProducerServiceProxy
producerServiceProxy
;
public
List
<
Offsets
>
produce
(
TransactionPayload
request
,
String
topic
,
TransactionRecorder
transactionRecorder
,
boolean
isReprocesed
)
{
//new
ResponseEntity
<
ConsumerPayload
>
response
=
producerServiceProxy
.
produceTransactionService
(
topic
,
request
,
"application/vnd.kafka.v2+json"
,
"producer"
);
//String topicUri = "/topics/".concat(topic);
//ResponseEntity<ConsumerPayload> response = restTemplate.postForEntity(topicUri, request, ConsumerPayload.class);
logger
.
info
(
"response ::response ::"
+
response
);
ResponseEntity
<
ConsumerPayload
>
response
=
producerServiceProxy
.
produceTransactionService
(
topic
,
request
);
logger
.
info
(
"response ::"
+
response
);
if
(
response
!=
null
&&
(
response
.
getStatusCodeValue
()
==
200
||
response
.
getStatusCode
().
is2xxSuccessful
()))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment